Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: return invalid document in error message #248

Merged
merged 46 commits into from
Jan 23, 2023
Merged
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
37ab522
fix: discard undefined security provider
y-lakhdar Dec 14, 2022
854d854
create permissionSetBuilder
y-lakhdar Dec 14, 2022
383306d
update comments
y-lakhdar Dec 14, 2022
1ff4898
add additional method to KnwonKey class
y-lakhdar Dec 14, 2022
fb95925
use `PermissionSetBuilder` class
y-lakhdar Dec 14, 2022
57dd8c1
unit tests
y-lakhdar Dec 14, 2022
d9a121e
lint
y-lakhdar Dec 14, 2022
7191904
make allowed and denied keys optional
y-lakhdar Dec 14, 2022
3945eee
use existing interfaces from platform-client
y-lakhdar Dec 16, 2022
97a1a19
parse permissions
y-lakhdar Dec 16, 2022
e1fabe6
support interface as records
y-lakhdar Dec 16, 2022
5369881
move parsePermission.spec.ts to future PR
y-lakhdar Dec 16, 2022
5729a06
fix UTs
y-lakhdar Dec 16, 2022
c010a6b
Merge branch 'CDX-1278' of github.com:coveo/push-api-client.js into C…
y-lakhdar Dec 16, 2022
746770e
test: update snapshots
y-lakhdar Dec 16, 2022
3718e75
Merge branch 'CDX-1278' of github.com:coveo/push-api-client.js into C…
y-lakhdar Dec 16, 2022
255ac7a
test: test permission parser
y-lakhdar Dec 16, 2022
ec3ee06
fix: prevent pushing empty permission array
y-lakhdar Dec 16, 2022
46dda23
lint
y-lakhdar Dec 16, 2022
ee433ef
Merge branch 'CDX-1280' of github.com:coveo/push-api-client.js into C…
y-lakhdar Dec 16, 2022
90826ec
remove comments
y-lakhdar Dec 16, 2022
b6c72df
BREAKING CHANGE: remove deprecated methods
y-lakhdar Dec 16, 2022
bf3efa2
lint
y-lakhdar Dec 16, 2022
60848c3
chore: remove unused imports
y-lakhdar Dec 16, 2022
0116ab6
set identitytype value case insensitive
y-lakhdar Dec 19, 2022
c39cb9f
test: update unit tests
y-lakhdar Dec 20, 2022
e720507
refactor: extend caseInsensitiveDocument
y-lakhdar Dec 21, 2022
025af74
add document in error in error class
y-lakhdar Dec 21, 2022
3392ba6
reorder parameters
y-lakhdar Dec 21, 2022
c12f7b0
test: add UTs
y-lakhdar Dec 21, 2022
492eb4e
rename method
y-lakhdar Dec 21, 2022
f0cc301
final version
y-lakhdar Dec 21, 2022
9363097
lint
y-lakhdar Dec 21, 2022
1353913
remove comment
y-lakhdar Dec 21, 2022
94cef6c
Merge branch 'main' of github.com:coveo/push-api-client.js into CDX-1278
y-lakhdar Jan 20, 2023
0aad0ac
lock
y-lakhdar Jan 20, 2023
06c7980
Merge branch 'CDX-1278' into CDX-1280
y-lakhdar Jan 20, 2023
1f42c80
Merge branch 'CDX-1280' of github.com:coveo/push-api-client.js into C…
y-lakhdar Jan 20, 2023
df92f68
Merge branch 'CDX-1282' into CDX-1283
y-lakhdar Jan 20, 2023
90b8129
Merge branch 'CDX-1283' of github.com:coveo/push-api-client.js into C…
y-lakhdar Jan 20, 2023
a872de7
fix snapshot
y-lakhdar Jan 20, 2023
ec36263
Merge branch 'main' of github.com:coveo/push-api-client.js into CDX-1283
y-lakhdar Jan 23, 2023
81f0d56
Merge branch 'CDX-1283' of github.com:coveo/push-api-client.js into C…
y-lakhdar Jan 23, 2023
15e2448
Merge branch 'CDX-1283' of github.com:coveo/push-api-client.js into C…
y-lakhdar Jan 23, 2023
ad48522
apply corrections
y-lakhdar Jan 23, 2023
989abbd
Merge branch 'main' of github.com:coveo/push-api-client.js into CDX-1284
y-lakhdar Jan 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reorder parameters
y-lakhdar committed Dec 21, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 3392ba6b77deb44c44551730958f0a8a529ed08e
11 changes: 7 additions & 4 deletions src/errors/validatorErrors.ts
Original file line number Diff line number Diff line change
@@ -17,10 +17,11 @@ export class NotAJsonFileError extends PushApiClientBaseError {

export class InvalidDocument extends PushApiClientBaseError {
public name = 'Invalid JSON Document Error';
private doc: Readonly<Record<string, PrimitivesValues>>;
public constructor(
p: PathLike,
explanation: string,
private invalidDocument: Record<string, PrimitivesValues>
doc: Record<string, PrimitivesValues>,
explanation: string
) {
super(
[
@@ -30,9 +31,11 @@ export class InvalidDocument extends PushApiClientBaseError {
' • Document Body reference: https://docs.coveo.com/en/75#documentbody',
].join('\n')
);
this.doc = doc;
}
public get document(): Readonly<Record<string, PrimitivesValues>> {
return this.invalidDocument;

public get document() {
return this.doc;
}
}

12 changes: 6 additions & 6 deletions src/validation/parseFile.ts
Original file line number Diff line number Diff line change
@@ -72,8 +72,8 @@ const processDocument = (
if (typeof error === 'string') {
throw new InvalidDocument(
documentPath,
error,
caseInsensitiveDoc.originalDocument
caseInsensitiveDoc.originalDocument,
error
);
}
throw error;
@@ -94,8 +94,8 @@ const validateRequiredKeysAndGetDocumentBuilder = (
if (!requiredDocumentId.isValid) {
throw new InvalidDocument(
documentPath,
requiredDocumentId.explanation,
caseInsensitiveDoc.originalDocument
caseInsensitiveDoc.originalDocument,
requiredDocumentId.explanation
);
}

@@ -107,8 +107,8 @@ const validateRequiredKeysAndGetDocumentBuilder = (
if (!requiredDocumentTitle.isValid) {
throw new InvalidDocument(
documentPath,
requiredDocumentTitle.explanation,
caseInsensitiveDoc.originalDocument
caseInsensitiveDoc.originalDocument,
requiredDocumentTitle.explanation
);
}

4 changes: 2 additions & 2 deletions src/validation/parsePermissions.ts
Original file line number Diff line number Diff line change
@@ -212,8 +212,8 @@ class PermissionParser {
private throwInvalidDocumentError(explanation: string): never {
throw new InvalidDocument(
this.documentPath,
explanation,
this.caseInsensitiveDoc.originalDocument
this.caseInsensitiveDoc.originalDocument,
explanation
);
}
}