@andco/protocol 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/api-errors.d.ts +5 -128
  2. package/dist/api-errors.d.ts.map +1 -1
  3. package/dist/api-errors.js +5 -131
  4. package/dist/authorization-preparation.d.ts +3 -3
  5. package/dist/authorization-preparation.d.ts.map +1 -1
  6. package/dist/authorization-preparation.js +4 -0
  7. package/dist/authorization.js +2 -2
  8. package/dist/errors.d.ts +60 -16
  9. package/dist/errors.d.ts.map +1 -1
  10. package/dist/errors.js +60 -12
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1 -0
  14. package/dist/intent-input.d.ts +1791 -725
  15. package/dist/intent-input.d.ts.map +1 -1
  16. package/dist/intent-input.js +325 -157
  17. package/dist/issues.d.ts +61 -0
  18. package/dist/issues.d.ts.map +1 -0
  19. package/dist/issues.js +61 -0
  20. package/dist/messages/index.d.ts +2 -2
  21. package/dist/messages/index.d.ts.map +1 -1
  22. package/dist/messages/index.js +10 -3
  23. package/dist/messages/set-preferences.d.ts +13 -1
  24. package/dist/messages/set-preferences.d.ts.map +1 -1
  25. package/dist/messages/set-preferences.js +31 -9
  26. package/dist/miniapp-manifest.d.ts +2 -2
  27. package/dist/miniapp-manifest.d.ts.map +1 -1
  28. package/dist/miniapp-manifest.js +1 -1
  29. package/dist/native-intent.d.ts +48 -28
  30. package/dist/native-intent.d.ts.map +1 -1
  31. package/dist/native-intent.js +76 -24
  32. package/dist/pagination.d.ts +37 -31
  33. package/dist/pagination.d.ts.map +1 -1
  34. package/dist/pagination.js +72 -24
  35. package/dist/rar/account-matchers.d.ts +47 -240
  36. package/dist/rar/account-matchers.d.ts.map +1 -1
  37. package/dist/rar/account-matchers.js +52 -131
  38. package/dist/rar/bank.d.ts +280 -392
  39. package/dist/rar/bank.d.ts.map +1 -1
  40. package/dist/rar/bank.js +68 -137
  41. package/dist/rar/catalog.d.ts +305 -288
  42. package/dist/rar/catalog.d.ts.map +1 -1
  43. package/dist/rar/catalog.js +69 -29
  44. package/dist/rar/detail.d.ts +15 -32
  45. package/dist/rar/detail.d.ts.map +1 -1
  46. package/dist/rar/detail.js +14 -34
  47. package/dist/rar/index.d.ts +2 -1
  48. package/dist/rar/index.d.ts.map +1 -1
  49. package/dist/rar/index.js +2 -1
  50. package/dist/rar/json-schemas.generated.d.ts +4 -0
  51. package/dist/rar/json-schemas.generated.d.ts.map +1 -0
  52. package/dist/rar/json-schemas.generated.js +3570 -0
  53. package/dist/rar/money.d.ts +5 -5
  54. package/dist/rar/money.d.ts.map +1 -1
  55. package/dist/rar/money.js +5 -5
  56. package/dist/rar/project-users.d.ts +40 -14
  57. package/dist/rar/project-users.d.ts.map +1 -1
  58. package/dist/rar/project-users.js +20 -23
  59. package/dist/rar/subject-data.d.ts +96 -48
  60. package/dist/rar/subject-data.d.ts.map +1 -1
  61. package/dist/rar/subject-data.js +61 -34
  62. package/dist/rar/subject.d.ts +18 -85
  63. package/dist/rar/subject.d.ts.map +1 -1
  64. package/dist/rar/subject.js +23 -51
  65. package/dist/rest/accounts.d.ts +347 -0
  66. package/dist/rest/accounts.d.ts.map +1 -0
  67. package/dist/rest/accounts.js +108 -0
  68. package/dist/rest/addresses.d.ts +581 -0
  69. package/dist/rest/addresses.d.ts.map +1 -0
  70. package/dist/rest/addresses.js +190 -0
  71. package/dist/rest/api-error.d.ts +104 -0
  72. package/dist/rest/api-error.d.ts.map +1 -0
  73. package/dist/rest/api-error.js +103 -0
  74. package/dist/rest/authorization.d.ts +123 -0
  75. package/dist/rest/authorization.d.ts.map +1 -0
  76. package/dist/rest/authorization.js +62 -0
  77. package/dist/rest/catalog.d.ts +199 -0
  78. package/dist/rest/catalog.d.ts.map +1 -0
  79. package/dist/rest/catalog.js +63 -0
  80. package/dist/rest/common.d.ts +637 -0
  81. package/dist/rest/common.d.ts.map +1 -0
  82. package/dist/rest/common.js +172 -0
  83. package/dist/rest/contract.d.ts +3480 -0
  84. package/dist/rest/contract.d.ts.map +1 -0
  85. package/dist/rest/contract.js +120 -0
  86. package/dist/rest/events.d.ts +145 -0
  87. package/dist/rest/events.d.ts.map +1 -0
  88. package/dist/rest/events.js +42 -0
  89. package/dist/rest/http.d.ts +49 -0
  90. package/dist/rest/http.d.ts.map +1 -0
  91. package/dist/rest/http.js +25 -0
  92. package/dist/rest/identity.d.ts +627 -0
  93. package/dist/rest/identity.d.ts.map +1 -0
  94. package/dist/rest/identity.js +128 -0
  95. package/dist/rest/index.d.ts +14 -0
  96. package/dist/rest/index.d.ts.map +1 -0
  97. package/dist/rest/index.js +13 -0
  98. package/dist/rest/intents.d.ts +4556 -0
  99. package/dist/rest/intents.d.ts.map +1 -0
  100. package/dist/rest/intents.js +551 -0
  101. package/dist/rest/signatures.d.ts +110 -0
  102. package/dist/rest/signatures.d.ts.map +1 -0
  103. package/dist/rest/signatures.js +113 -0
  104. package/dist/rest/subjects.d.ts +14 -0
  105. package/dist/rest/subjects.d.ts.map +1 -0
  106. package/dist/rest/subjects.js +22 -0
  107. package/dist/service-grants.d.ts +2 -2
  108. package/dist/service-grants.d.ts.map +1 -1
  109. package/dist/service-grants.js +1 -1
  110. package/dist/transport/generated/oauth-api.d.ts +5547 -1448
  111. package/dist/transport/generated/oauth-api.d.ts.map +1 -1
  112. package/dist/transport/intents.d.ts +9 -134
  113. package/dist/transport/intents.d.ts.map +1 -1
  114. package/dist/transport/intents.js +21 -405
  115. package/dist/transport/rest.d.ts +15 -5
  116. package/dist/transport/rest.d.ts.map +1 -1
  117. package/dist/userinfo.d.ts +22 -9
  118. package/dist/userinfo.d.ts.map +1 -1
  119. package/dist/userinfo.js +17 -12
  120. package/package.json +13 -2
@@ -6,8 +6,8 @@ import * as v from "valibot";
6
6
  * Fifteen digits, not sixteen, and not because that is the largest value `Number.isSafeInteger`
7
7
  * tolerates -- `9999999999999999` (sixteen digits) already passes that check today and still turns
8
8
  * into a different number the moment something calls `Number()` on it. The real ceiling is set by
9
- * the weaker of the two engines that evaluate this same scalar: valibot here, and the JSON Schema
10
- * mirrors of every authorization detail, which travel into the Postgres seeds that are the only
9
+ * the weaker of the two engines that evaluate this same scalar: valibot here, and the JSON Schemas
10
+ * generated for every authorization detail, which travel into the Postgres seeds that are the only
11
11
  * place an authorization detail is actually gated. JSON Schema's `pattern` matches a string; its
12
12
  * `maximum` matches a number. There is nowhere in those seeds to hang a `Number.isSafeInteger`-shaped
13
13
  * check on a string field, so the only bound JSON Schema can enforce here is a digit count baked into
@@ -43,8 +43,8 @@ export declare const MINIMUM_TRANSACTION_AMOUNT = "1000";
43
43
  * because only the limits of a permission carry the floor; a Transaction read back from the ledger
44
44
  * may be smaller.
45
45
  *
46
- * The floor lives in the regex, rather than in a numeric comparison, because the JSON Schema mirror
47
- * has no numeric comparison over strings: this way both engines enforce the same bound.
46
+ * The floor lives in the regex, rather than in a numeric comparison, because the generated JSON
47
+ * Schema has no numeric comparison over strings: this way both engines enforce the same bound.
48
48
  *
49
49
  * @example
50
50
  * new RegExp(TRANSACTION_LIMIT_PATTERN).test("1000"); // true
@@ -52,7 +52,7 @@ export declare const MINIMUM_TRANSACTION_AMOUNT = "1000";
52
52
  */
53
53
  export declare const TRANSACTION_LIMIT_PATTERN = "^[1-9][0-9]{3,14}$";
54
54
  /** A permission's amount limit: {@link MoneySchema} at or above {@link MINIMUM_TRANSACTION_AMOUNT}. */
55
- export declare const TransactionLimitSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "amount_below_minimum_or_malformed">]>;
55
+ export declare const TransactionLimitSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
56
56
  /** Compares two strings that already passed {@link MoneySchema}, without ever calling `Number()`. */
57
57
  export declare function compareMoney(left: Money, right: Money): -1 | 0 | 1;
58
58
  //# sourceMappingURL=money.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../../src/rar/money.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa,uBAAuB,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAE9D,qEAAqE;AACrE,eAAO,MAAM,WAAW,0FAAyE,CAAC;AAClG,4EAA4E;AAC5E,eAAO,MAAM,iBAAiB,0FAAiF,CAAC;AAEhH,uEAAuE;AACvE,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAE3B;;;GAGG;AACH,eAAO,MAAM,0BAA0B,SAAS,CAAC;AAEjD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D,uGAAuG;AACvG,eAAO,MAAM,sBAAsB,oHAGlC,CAAC;AAEF,qGAAqG;AACrG,wBAAgB,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAKlE"}
1
+ {"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../../src/rar/money.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa,uBAAuB,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAE9D,qEAAqE;AACrE,eAAO,MAAM,WAAW,0FAAyE,CAAC;AAClG,4EAA4E;AAC5E,eAAO,MAAM,iBAAiB,0FAAiF,CAAC;AAEhH,uEAAuE;AACvE,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAE3B;;;GAGG;AACH,eAAO,MAAM,0BAA0B,SAAS,CAAC;AAEjD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D,uGAAuG;AACvG,eAAO,MAAM,sBAAsB,0FAGlC,CAAC;AAEF,qGAAqG;AACrG,wBAAgB,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAKlE"}
package/dist/rar/money.js CHANGED
@@ -6,8 +6,8 @@ import * as v from "valibot";
6
6
  * Fifteen digits, not sixteen, and not because that is the largest value `Number.isSafeInteger`
7
7
  * tolerates -- `9999999999999999` (sixteen digits) already passes that check today and still turns
8
8
  * into a different number the moment something calls `Number()` on it. The real ceiling is set by
9
- * the weaker of the two engines that evaluate this same scalar: valibot here, and the JSON Schema
10
- * mirrors of every authorization detail, which travel into the Postgres seeds that are the only
9
+ * the weaker of the two engines that evaluate this same scalar: valibot here, and the JSON Schemas
10
+ * generated for every authorization detail, which travel into the Postgres seeds that are the only
11
11
  * place an authorization detail is actually gated. JSON Schema's `pattern` matches a string; its
12
12
  * `maximum` matches a number. There is nowhere in those seeds to hang a `Number.isSafeInteger`-shaped
13
13
  * check on a string field, so the only bound JSON Schema can enforce here is a digit count baked into
@@ -41,8 +41,8 @@ export const MINIMUM_TRANSACTION_AMOUNT = "1000";
41
41
  * because only the limits of a permission carry the floor; a Transaction read back from the ledger
42
42
  * may be smaller.
43
43
  *
44
- * The floor lives in the regex, rather than in a numeric comparison, because the JSON Schema mirror
45
- * has no numeric comparison over strings: this way both engines enforce the same bound.
44
+ * The floor lives in the regex, rather than in a numeric comparison, because the generated JSON
45
+ * Schema has no numeric comparison over strings: this way both engines enforce the same bound.
46
46
  *
47
47
  * @example
48
48
  * new RegExp(TRANSACTION_LIMIT_PATTERN).test("1000"); // true
@@ -50,7 +50,7 @@ export const MINIMUM_TRANSACTION_AMOUNT = "1000";
50
50
  */
51
51
  export const TRANSACTION_LIMIT_PATTERN = "^[1-9][0-9]{3,14}$";
52
52
  /** A permission's amount limit: {@link MoneySchema} at or above {@link MINIMUM_TRANSACTION_AMOUNT}. */
53
- export const TransactionLimitSchema = /* @__PURE__ */ v.pipe(v.string(), v.regex(new RegExp(TRANSACTION_LIMIT_PATTERN), "amount_below_minimum_or_malformed"));
53
+ export const TransactionLimitSchema = /* @__PURE__ */ v.pipe(v.string(), v.regex(new RegExp(TRANSACTION_LIMIT_PATTERN)));
54
54
  /** Compares two strings that already passed {@link MoneySchema}, without ever calling `Number()`. */
55
55
  export function compareMoney(left, right) {
56
56
  const a = BigInt(left);
@@ -1,4 +1,5 @@
1
1
  import * as v from "valibot";
2
+ import { type Issue } from "../issues.js";
2
3
  /** Reading the Profiles of a Project's users: `GET /projects/{project_id}/profiles`. */
3
4
  export declare const PROJECT_USERS_ACTIONS: readonly ["read"];
4
5
  /** The Profile fields a `project_users` detail may expose. An empty or absent list means all of them. */
@@ -19,25 +20,50 @@ export declare const PROJECT_USERS_FIELDS: readonly ["id", "name", "email", "ava
19
20
  */
20
21
  export declare const ProjectUsersGrantRequestSchema: v.StrictObjectSchema<{
21
22
  readonly type: v.LiteralSchema<"project_users", undefined>;
22
- readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read"], undefined>, undefined>, v.MinLengthAction<"read"[], 1, undefined>, v.CheckAction<"read"[], "duplicate_action">]>;
23
- readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
24
- readonly project_ids: v.NullishSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>, v.MaxLengthAction<string[], 100, undefined>, v.CheckAction<string[], "duplicate_identifier">]>, undefined>;
25
- readonly client_ids: v.NullishSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>, v.MaxLengthAction<string[], 100, undefined>, v.CheckAction<string[], "duplicate_identifier">]>, undefined>;
26
- readonly fields: v.NullishSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["id", "name", "email", "avatar", "phone", "identities", "addresses"], undefined>, undefined>, v.CheckAction<("email" | "phone" | "id" | "name" | "avatar" | "identities" | "addresses")[], "duplicate_field">]>, undefined>;
23
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read"], undefined>, undefined>, v.MinLengthAction<"read"[], 1, undefined>, v.MetadataAction<"read"[], {
24
+ readonly uniqueItems: true;
25
+ }>]>;
26
+ readonly locations: v.StrictTupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
27
+ readonly project_ids: v.NullishSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>, v.MaxLengthAction<string[], 100, undefined>, v.MetadataAction<string[], {
28
+ readonly uniqueItems: true;
29
+ }>]>, undefined>;
30
+ readonly client_ids: v.NullishSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>, v.MaxLengthAction<string[], 100, undefined>, v.MetadataAction<string[], {
31
+ readonly uniqueItems: true;
32
+ }>]>, undefined>;
33
+ readonly fields: v.NullishSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["id", "name", "email", "avatar", "phone", "identities", "addresses"], undefined>, undefined>, v.MetadataAction<("email" | "phone" | "id" | "name" | "avatar" | "identities" | "addresses")[], {
34
+ readonly uniqueItems: true;
35
+ }>]>, undefined>;
27
36
  }, undefined>;
28
37
  export type ProjectUsersGrantRequest = v.InferInput<typeof ProjectUsersGrantRequestSchema>;
29
38
  /** `project_users` Grant: the three lists always present, an empty one still meaning all. */
30
39
  export declare const ProjectUsersGrantSchema: v.StrictObjectSchema<{
31
40
  readonly type: v.LiteralSchema<"project_users", undefined>;
32
- readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read"], undefined>, undefined>, v.MinLengthAction<"read"[], 1, undefined>, v.CheckAction<"read"[], "duplicate_action">]>;
33
- readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
34
- readonly project_ids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>, v.MaxLengthAction<string[], 100, undefined>, v.CheckAction<string[], "duplicate_identifier">]>;
35
- readonly client_ids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>, v.MaxLengthAction<string[], 100, undefined>, v.CheckAction<string[], "duplicate_identifier">]>;
36
- readonly fields: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["id", "name", "email", "avatar", "phone", "identities", "addresses"], undefined>, undefined>, v.CheckAction<("email" | "phone" | "id" | "name" | "avatar" | "identities" | "addresses")[], "duplicate_field">]>;
41
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read"], undefined>, undefined>, v.MinLengthAction<"read"[], 1, undefined>, v.MetadataAction<"read"[], {
42
+ readonly uniqueItems: true;
43
+ }>]>;
44
+ readonly locations: v.StrictTupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
45
+ readonly project_ids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>, v.MaxLengthAction<string[], 100, undefined>, v.MetadataAction<string[], {
46
+ readonly uniqueItems: true;
47
+ }>]>;
48
+ readonly client_ids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>, v.MaxLengthAction<string[], 100, undefined>, v.MetadataAction<string[], {
49
+ readonly uniqueItems: true;
50
+ }>]>;
51
+ readonly fields: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["id", "name", "email", "avatar", "phone", "identities", "addresses"], undefined>, undefined>, v.MetadataAction<("email" | "phone" | "id" | "name" | "avatar" | "identities" | "addresses")[], {
52
+ readonly uniqueItems: true;
53
+ }>]>;
37
54
  }, undefined>;
38
55
  export type ProjectUsersGrant = v.InferOutput<typeof ProjectUsersGrantSchema>;
39
- /** JSON Schema mirror of {@link ProjectUsersGrantRequestSchema}. */
40
- export declare const PROJECT_USERS_GRANT_REQUEST_JSON_SCHEMA: Record<string, unknown>;
41
- /** JSON Schema mirror of {@link ProjectUsersGrantSchema}. */
42
- export declare const PROJECT_USERS_GRANT_JSON_SCHEMA: Record<string, unknown>;
56
+ /**
57
+ * The rules of a `project_users` detail, in either form: `duplicate_identifier` at a Project or
58
+ * Client id listed twice and `duplicate_field` at a field listed twice.
59
+ *
60
+ * @example
61
+ * projectUsersIssues({ project_ids: [], client_ids: [], fields: ["email", "email"] });
62
+ * // [{ type: "duplicate_field", path: [{ key: "fields" }, { key: 1 }] }]
63
+ */
64
+ export declare function projectUsersIssues(lists: {
65
+ readonly project_ids?: readonly string[] | null | undefined;
66
+ readonly client_ids?: readonly string[] | null | undefined;
67
+ readonly fields?: readonly string[] | null | undefined;
68
+ }): Issue[];
43
69
  //# sourceMappingURL=project-users.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"project-users.d.ts","sourceRoot":"","sources":["../../src/rar/project-users.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAU7B,wFAAwF;AACxF,eAAO,MAAM,qBAAqB,mBAAoB,CAAC;AAEvD,yGAAyG;AACzG,eAAO,MAAM,oBAAoB,gFAAiF,CAAC;AAmBnH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,8BAA8B;;;;;;;aAOzC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,UAAU,CAAC,OAAO,8BAA8B,CAAC,CAAC;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6 @@
1
1
  import * as v from "valibot";
2
- import { AndcoRarLocationsSchema, actionSet, actionSetJson, detailFormJson, detailTypeJson, nullableJson, } from "./detail.js";
2
+ import { duplicateIssues, issuesAt } from "../issues.js";
3
+ import { AndcoRarLocationsSchema, actionSet } from "./detail.js";
3
4
  /** Reading the Profiles of a Project's users: `GET /projects/{project_id}/profiles`. */
4
5
  export const PROJECT_USERS_ACTIONS = ["read"];
5
6
  /** The Profile fields a `project_users` detail may expose. An empty or absent list means all of them. */
@@ -8,9 +9,9 @@ export const PROJECT_USERS_FIELDS = ["id", "name", "email", "avatar", "phone", "
8
9
  const PROJECT_USERS_LIST_CEILING = 100;
9
10
  /** Project and Client ids are UUID-shaped; no version digit is checked, as with Profile identifiers. */
10
11
  const UUID_PATTERN = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$";
11
- const distinct = (values) => new Set(values).size === values.length;
12
- const uuidList = /* @__PURE__ */ v.pipe(v.array(v.pipe(v.string(), v.regex(new RegExp(UUID_PATTERN)))), v.maxLength(PROJECT_USERS_LIST_CEILING), v.check((values) => distinct(values), "duplicate_identifier"));
13
- const fieldList = /* @__PURE__ */ v.pipe(v.array(v.picklist(PROJECT_USERS_FIELDS)), v.check((values) => distinct(values), "duplicate_field"));
12
+ // Distinct values are `uniqueItems` in JSON Schema and the rule {@link projectUsersIssues} here.
13
+ const uuidList = /* @__PURE__ */ v.pipe(v.array(v.pipe(v.string(), v.regex(new RegExp(UUID_PATTERN)))), v.maxLength(PROJECT_USERS_LIST_CEILING), v.metadata({ uniqueItems: true }));
14
+ const fieldList = /* @__PURE__ */ v.pipe(v.array(v.picklist(PROJECT_USERS_FIELDS)), v.metadata({ uniqueItems: true }));
14
15
  /**
15
16
  * `project_users` Grant Request, only for `service` clients: read the users of the client's
16
17
  * Projects. It has no subject: the Projects are the boundary. An empty or absent `project_ids`,
@@ -42,22 +43,18 @@ export const ProjectUsersGrantSchema = /* @__PURE__ */ v.strictObject({
42
43
  client_ids: uuidList,
43
44
  fields: fieldList,
44
45
  });
45
- const uuidListJson = {
46
- type: "array",
47
- maxItems: PROJECT_USERS_LIST_CEILING,
48
- uniqueItems: true,
49
- items: { type: "string", pattern: UUID_PATTERN },
50
- };
51
- const fieldListJson = { type: "array", uniqueItems: true, items: { enum: [...PROJECT_USERS_FIELDS] } };
52
- /** JSON Schema mirror of {@link ProjectUsersGrantRequestSchema}. */
53
- export const PROJECT_USERS_GRANT_REQUEST_JSON_SCHEMA = /* @__PURE__ */ detailTypeJson([
54
- detailFormJson("project_users", actionSetJson(PROJECT_USERS_ACTIONS), {
55
- project_ids: nullableJson(uuidListJson),
56
- client_ids: nullableJson(uuidListJson),
57
- fields: nullableJson(fieldListJson),
58
- }, []),
59
- ]);
60
- /** JSON Schema mirror of {@link ProjectUsersGrantSchema}. */
61
- export const PROJECT_USERS_GRANT_JSON_SCHEMA = /* @__PURE__ */ detailTypeJson([
62
- detailFormJson("project_users", actionSetJson(PROJECT_USERS_ACTIONS), { project_ids: uuidListJson, client_ids: uuidListJson, fields: fieldListJson }, ["project_ids", "client_ids", "fields"]),
63
- ]);
46
+ /**
47
+ * The rules of a `project_users` detail, in either form: `duplicate_identifier` at a Project or
48
+ * Client id listed twice and `duplicate_field` at a field listed twice.
49
+ *
50
+ * @example
51
+ * projectUsersIssues({ project_ids: [], client_ids: [], fields: ["email", "email"] });
52
+ * // [{ type: "duplicate_field", path: [{ key: "fields" }, { key: 1 }] }]
53
+ */
54
+ export function projectUsersIssues(lists) {
55
+ return [
56
+ ...issuesAt(["project_ids"], duplicateIssues(lists.project_ids ?? [], "duplicate_identifier")),
57
+ ...issuesAt(["client_ids"], duplicateIssues(lists.client_ids ?? [], "duplicate_identifier")),
58
+ ...issuesAt(["fields"], duplicateIssues(lists.fields ?? [], "duplicate_field")),
59
+ ];
60
+ }
@@ -8,7 +8,24 @@ export declare const ORGANIZATION_ACTIONS: readonly ["list"];
8
8
  /** Editing the signed-in person's Profile. Replaces the former `profile:write` scope. */
9
9
  export declare const PROFILE_ACTIONS: readonly ["update"];
10
10
  /**
11
- * `identity` Grant Request: read the identity of a Profile or an Organization.
11
+ * The `validation` of an `identity` detail: the application asks that Andco Core has validated the
12
+ * person's identity (the ID card, a liveness check and the comparison of the face with the card's),
13
+ * and reads that validation together with the identity.
14
+ *
15
+ * `required` admits only `true`: a detail that does not need the validation leaves `validation` out
16
+ * instead of writing `required: false`. The object is where an age limit can enter later.
17
+ *
18
+ * @example
19
+ * const validation: IdentityValidation = { required: true };
20
+ */
21
+ export declare const IdentityValidationSchema: v.StrictObjectSchema<{
22
+ readonly required: v.LiteralSchema<true, undefined>;
23
+ }, undefined>;
24
+ export type IdentityValidation = v.InferOutput<typeof IdentityValidationSchema>;
25
+ /**
26
+ * `identity` Grant Request: read the identity of a Profile or an Organization. Two forms: a Profile
27
+ * (named, or the signed-in one by default) may also ask for its {@link IdentityValidationSchema | validation};
28
+ * an Organization is never validated, so its form has no `validation`.
12
29
  *
13
30
  * @example
14
31
  * const kyb: IdentityGrantRequest = {
@@ -17,34 +34,69 @@ export declare const PROFILE_ACTIONS: readonly ["update"];
17
34
  * locations: ["https://api.andco.com"],
18
35
  * subject: { type: "organization" },
19
36
  * };
37
+ *
38
+ * @example
39
+ * const validated: IdentityGrantRequest = {
40
+ * type: "identity",
41
+ * actions: ["read"],
42
+ * locations: ["https://api.andco.com"],
43
+ * subject: { type: "profile" },
44
+ * validation: { required: true },
45
+ * };
20
46
  */
21
- export declare const IdentityGrantRequestSchema: v.StrictObjectSchema<{
47
+ export declare const IdentityGrantRequestSchema: v.UnionSchema<[v.StrictObjectSchema<{
22
48
  readonly type: v.LiteralSchema<"identity", undefined>;
23
- readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read"], undefined>, undefined>, v.MinLengthAction<"read"[], 1, undefined>, v.CheckAction<"read"[], "duplicate_action">]>;
24
- readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
25
- readonly subject: v.NullishSchema<v.VariantSchema<"type", [v.StrictObjectSchema<{
49
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read"], undefined>, undefined>, v.MinLengthAction<"read"[], 1, undefined>, v.MetadataAction<"read"[], {
50
+ readonly uniqueItems: true;
51
+ }>]>;
52
+ readonly locations: v.StrictTupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
53
+ readonly subject: v.NullishSchema<v.StrictObjectSchema<{
26
54
  readonly type: v.LiteralSchema<"profile", undefined>;
27
55
  readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
28
- }, undefined>, v.StrictObjectSchema<{
56
+ }, undefined>, undefined>;
57
+ readonly validation: v.NullishSchema<v.StrictObjectSchema<{
58
+ readonly required: v.LiteralSchema<true, undefined>;
59
+ }, undefined>, undefined>;
60
+ }, undefined>, v.StrictObjectSchema<{
61
+ readonly type: v.LiteralSchema<"identity", undefined>;
62
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read"], undefined>, undefined>, v.MinLengthAction<"read"[], 1, undefined>, v.MetadataAction<"read"[], {
63
+ readonly uniqueItems: true;
64
+ }>]>;
65
+ readonly locations: v.StrictTupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
66
+ readonly subject: v.StrictObjectSchema<{
29
67
  readonly type: v.LiteralSchema<"organization", undefined>;
30
- readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.CheckAction<string, "identifier_exceeds_organization_id">]>, undefined>;
68
+ readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
31
69
  readonly editable: v.NullishSchema<v.BooleanSchema<undefined>, undefined>;
32
- }, undefined>], undefined>, undefined>;
33
- }, undefined>;
70
+ }, undefined>;
71
+ readonly validation: v.OptionalSchema<v.NeverSchema<undefined>, undefined>;
72
+ }, undefined>], undefined>;
34
73
  export type IdentityGrantRequest = v.InferInput<typeof IdentityGrantRequestSchema>;
35
- /** `identity` Grant. */
36
- export declare const IdentityGrantSchema: v.StrictObjectSchema<{
74
+ /** `identity` Grant: the two forms with the subject resolved. `validation` stays only when it was asked. */
75
+ export declare const IdentityGrantSchema: v.UnionSchema<[v.StrictObjectSchema<{
37
76
  readonly type: v.LiteralSchema<"identity", undefined>;
38
- readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read"], undefined>, undefined>, v.MinLengthAction<"read"[], 1, undefined>, v.CheckAction<"read"[], "duplicate_action">]>;
39
- readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
40
- readonly subject: v.VariantSchema<"type", [v.StrictObjectSchema<{
77
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read"], undefined>, undefined>, v.MinLengthAction<"read"[], 1, undefined>, v.MetadataAction<"read"[], {
78
+ readonly uniqueItems: true;
79
+ }>]>;
80
+ readonly locations: v.StrictTupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
81
+ readonly subject: v.StrictObjectSchema<{
41
82
  readonly type: v.LiteralSchema<"profile", undefined>;
42
83
  readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
43
- }, undefined>, v.StrictObjectSchema<{
84
+ }, undefined>;
85
+ readonly validation: v.OptionalSchema<v.StrictObjectSchema<{
86
+ readonly required: v.LiteralSchema<true, undefined>;
87
+ }, undefined>, undefined>;
88
+ }, undefined>, v.StrictObjectSchema<{
89
+ readonly type: v.LiteralSchema<"identity", undefined>;
90
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read"], undefined>, undefined>, v.MinLengthAction<"read"[], 1, undefined>, v.MetadataAction<"read"[], {
91
+ readonly uniqueItems: true;
92
+ }>]>;
93
+ readonly locations: v.StrictTupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
94
+ readonly subject: v.StrictObjectSchema<{
44
95
  readonly type: v.LiteralSchema<"organization", undefined>;
45
- readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.CheckAction<string, "identifier_exceeds_organization_id">]>;
46
- }, undefined>], undefined>;
47
- }, undefined>;
96
+ readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
97
+ }, undefined>;
98
+ readonly validation: v.OptionalSchema<v.NeverSchema<undefined>, undefined>;
99
+ }, undefined>], undefined>;
48
100
  export type IdentityGrant = v.InferOutput<typeof IdentityGrantSchema>;
49
101
  /**
50
102
  * `address` Grant Request: read or manage the addresses of a Profile or an Organization.
@@ -59,14 +111,16 @@ export type IdentityGrant = v.InferOutput<typeof IdentityGrantSchema>;
59
111
  */
60
112
  export declare const AddressGrantRequestSchema: v.StrictObjectSchema<{
61
113
  readonly type: v.LiteralSchema<"address", undefined>;
62
- readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read", "create", "update", "delete"], undefined>, undefined>, v.MinLengthAction<("read" | "create" | "update" | "delete")[], 1, undefined>, v.CheckAction<("read" | "create" | "update" | "delete")[], "duplicate_action">]>;
63
- readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
114
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read", "create", "update", "delete"], undefined>, undefined>, v.MinLengthAction<("read" | "create" | "update" | "delete")[], 1, undefined>, v.MetadataAction<("read" | "create" | "update" | "delete")[], {
115
+ readonly uniqueItems: true;
116
+ }>]>;
117
+ readonly locations: v.StrictTupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
64
118
  readonly subject: v.NullishSchema<v.VariantSchema<"type", [v.StrictObjectSchema<{
65
119
  readonly type: v.LiteralSchema<"profile", undefined>;
66
120
  readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
67
121
  }, undefined>, v.StrictObjectSchema<{
68
122
  readonly type: v.LiteralSchema<"organization", undefined>;
69
- readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.CheckAction<string, "identifier_exceeds_organization_id">]>, undefined>;
123
+ readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
70
124
  readonly editable: v.NullishSchema<v.BooleanSchema<undefined>, undefined>;
71
125
  }, undefined>], undefined>, undefined>;
72
126
  }, undefined>;
@@ -74,14 +128,16 @@ export type AddressGrantRequest = v.InferInput<typeof AddressGrantRequestSchema>
74
128
  /** `address` Grant. */
75
129
  export declare const AddressGrantSchema: v.StrictObjectSchema<{
76
130
  readonly type: v.LiteralSchema<"address", undefined>;
77
- readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read", "create", "update", "delete"], undefined>, undefined>, v.MinLengthAction<("read" | "create" | "update" | "delete")[], 1, undefined>, v.CheckAction<("read" | "create" | "update" | "delete")[], "duplicate_action">]>;
78
- readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
131
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["read", "create", "update", "delete"], undefined>, undefined>, v.MinLengthAction<("read" | "create" | "update" | "delete")[], 1, undefined>, v.MetadataAction<("read" | "create" | "update" | "delete")[], {
132
+ readonly uniqueItems: true;
133
+ }>]>;
134
+ readonly locations: v.StrictTupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
79
135
  readonly subject: v.VariantSchema<"type", [v.StrictObjectSchema<{
80
136
  readonly type: v.LiteralSchema<"profile", undefined>;
81
137
  readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
82
138
  }, undefined>, v.StrictObjectSchema<{
83
139
  readonly type: v.LiteralSchema<"organization", undefined>;
84
- readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.CheckAction<string, "identifier_exceeds_organization_id">]>;
140
+ readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
85
141
  }, undefined>], undefined>;
86
142
  }, undefined>;
87
143
  export type AddressGrant = v.InferOutput<typeof AddressGrantSchema>;
@@ -99,8 +155,10 @@ export type AddressGrant = v.InferOutput<typeof AddressGrantSchema>;
99
155
  */
100
156
  export declare const OrganizationGrantRequestSchema: v.StrictObjectSchema<{
101
157
  readonly type: v.LiteralSchema<"organization", undefined>;
102
- readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["list"], undefined>, undefined>, v.MinLengthAction<"list"[], 1, undefined>, v.CheckAction<"list"[], "duplicate_action">]>;
103
- readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
158
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["list"], undefined>, undefined>, v.MinLengthAction<"list"[], 1, undefined>, v.MetadataAction<"list"[], {
159
+ readonly uniqueItems: true;
160
+ }>]>;
161
+ readonly locations: v.StrictTupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
104
162
  readonly subject: v.NullishSchema<v.StrictObjectSchema<{
105
163
  readonly type: v.LiteralSchema<"profile", undefined>;
106
164
  readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
@@ -110,8 +168,10 @@ export type OrganizationGrantRequest = v.InferInput<typeof OrganizationGrantRequ
110
168
  /** `organization` Grant. */
111
169
  export declare const OrganizationGrantSchema: v.StrictObjectSchema<{
112
170
  readonly type: v.LiteralSchema<"organization", undefined>;
113
- readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["list"], undefined>, undefined>, v.MinLengthAction<"list"[], 1, undefined>, v.CheckAction<"list"[], "duplicate_action">]>;
114
- readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
171
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["list"], undefined>, undefined>, v.MinLengthAction<"list"[], 1, undefined>, v.MetadataAction<"list"[], {
172
+ readonly uniqueItems: true;
173
+ }>]>;
174
+ readonly locations: v.StrictTupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
115
175
  readonly subject: v.StrictObjectSchema<{
116
176
  readonly type: v.LiteralSchema<"profile", undefined>;
117
177
  readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
@@ -132,8 +192,10 @@ export type OrganizationGrant = v.InferOutput<typeof OrganizationGrantSchema>;
132
192
  */
133
193
  export declare const ProfileGrantRequestSchema: v.StrictObjectSchema<{
134
194
  readonly type: v.LiteralSchema<"profile", undefined>;
135
- readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["update"], undefined>, undefined>, v.MinLengthAction<"update"[], 1, undefined>, v.CheckAction<"update"[], "duplicate_action">]>;
136
- readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
195
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["update"], undefined>, undefined>, v.MinLengthAction<"update"[], 1, undefined>, v.MetadataAction<"update"[], {
196
+ readonly uniqueItems: true;
197
+ }>]>;
198
+ readonly locations: v.StrictTupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
137
199
  readonly subject: v.NullishSchema<v.StrictObjectSchema<{
138
200
  readonly type: v.LiteralSchema<"profile", undefined>;
139
201
  readonly identifier: v.NullishSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
@@ -143,28 +205,14 @@ export type ProfileGrantRequest = v.InferInput<typeof ProfileGrantRequestSchema>
143
205
  /** `profile` Grant. */
144
206
  export declare const ProfileGrantSchema: v.StrictObjectSchema<{
145
207
  readonly type: v.LiteralSchema<"profile", undefined>;
146
- readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["update"], undefined>, undefined>, v.MinLengthAction<"update"[], 1, undefined>, v.CheckAction<"update"[], "duplicate_action">]>;
147
- readonly locations: v.TupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
208
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["update"], undefined>, undefined>, v.MinLengthAction<"update"[], 1, undefined>, v.MetadataAction<"update"[], {
209
+ readonly uniqueItems: true;
210
+ }>]>;
211
+ readonly locations: v.StrictTupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
148
212
  readonly subject: v.StrictObjectSchema<{
149
213
  readonly type: v.LiteralSchema<"profile", undefined>;
150
214
  readonly identifier: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
151
215
  }, undefined>;
152
216
  }, undefined>;
153
217
  export type ProfileGrant = v.InferOutput<typeof ProfileGrantSchema>;
154
- /** JSON Schema mirror of {@link IdentityGrantRequestSchema}. */
155
- export declare const IDENTITY_GRANT_REQUEST_JSON_SCHEMA: Record<string, unknown>;
156
- /** JSON Schema mirror of {@link IdentityGrantSchema}. */
157
- export declare const IDENTITY_GRANT_JSON_SCHEMA: Record<string, unknown>;
158
- /** JSON Schema mirror of {@link AddressGrantRequestSchema}. */
159
- export declare const ADDRESS_GRANT_REQUEST_JSON_SCHEMA: Record<string, unknown>;
160
- /** JSON Schema mirror of {@link AddressGrantSchema}. */
161
- export declare const ADDRESS_GRANT_JSON_SCHEMA: Record<string, unknown>;
162
- /** JSON Schema mirror of {@link OrganizationGrantRequestSchema}. */
163
- export declare const ORGANIZATION_GRANT_REQUEST_JSON_SCHEMA: Record<string, unknown>;
164
- /** JSON Schema mirror of {@link OrganizationGrantSchema}. */
165
- export declare const ORGANIZATION_GRANT_JSON_SCHEMA: Record<string, unknown>;
166
- /** JSON Schema mirror of {@link ProfileGrantRequestSchema}. */
167
- export declare const PROFILE_GRANT_REQUEST_JSON_SCHEMA: Record<string, unknown>;
168
- /** JSON Schema mirror of {@link ProfileGrantSchema}. */
169
- export declare const PROFILE_GRANT_JSON_SCHEMA: Record<string, unknown>;
170
218
  //# sourceMappingURL=subject-data.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"subject-data.d.ts","sourceRoot":"","sources":["../../src/rar/subject-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAa7B,2GAA2G;AAC3G,eAAO,MAAM,gBAAgB,mBAAoB,CAAC;AAClD,4GAA4G;AAC5G,eAAO,MAAM,eAAe,iDAAkD,CAAC;AAC/E,wFAAwF;AACxF,eAAO,MAAM,oBAAoB,mBAAoB,CAAC;AACtD,yFAAyF;AACzF,eAAO,MAAM,eAAe,qBAAsB,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;aAKrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC;AACnF,wBAAwB;AACxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;aAK9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;aAKpC,CAAC;AACH,MAAM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;aAKzC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,UAAU,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAC3F,4BAA4B;AAC5B,eAAO,MAAM,uBAAuB;;;;;;;;;;aAKlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;aAKpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AACjF,uBAAuB;AACvB,eAAO,MAAM,kBAAkB;;;;;;;;;;aAK7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import * as v from "valibot";
2
- import { AndcoRarLocationsSchema, actionSet, actionSetJson, detailFormJson, detailTypeJson } from "./detail.js";
3
- import { GRANTED_PROFILE_SUBJECT_JSON_SCHEMA, GRANTED_SUBJECT_JSON_SCHEMA, GrantedProfileSubjectSchema, GrantedSubjectSchema, PROFILE_ONLY_SUBJECT_PICKER_JSON_SCHEMA, ProfileOnlySubjectPickerSchema, SUBJECT_PICKER_JSON_SCHEMA, SubjectPickerSchema, } from "./subject.js";
2
+ import { AndcoRarLocationsSchema, actionSet } from "./detail.js";
3
+ import { GrantedOrganizationSubjectSchema, GrantedProfileSubjectSchema, GrantedSubjectSchema, OrganizationSubjectPickerSchema, ProfileOnlySubjectPickerSchema, SubjectPickerSchema, } from "./subject.js";
4
4
  /** Reading the Subject's identity: `GET /profiles/{id}/identities` or `/organizations/{id}/identities`. */
5
5
  export const IDENTITY_ACTIONS = ["read"];
6
6
  /** Managing the Subject's addresses under `/profiles/{id}/addresses` or `/organizations/{id}/addresses`. */
@@ -10,7 +10,21 @@ export const ORGANIZATION_ACTIONS = ["list"];
10
10
  /** Editing the signed-in person's Profile. Replaces the former `profile:write` scope. */
11
11
  export const PROFILE_ACTIONS = ["update"];
12
12
  /**
13
- * `identity` Grant Request: read the identity of a Profile or an Organization.
13
+ * The `validation` of an `identity` detail: the application asks that Andco Core has validated the
14
+ * person's identity (the ID card, a liveness check and the comparison of the face with the card's),
15
+ * and reads that validation together with the identity.
16
+ *
17
+ * `required` admits only `true`: a detail that does not need the validation leaves `validation` out
18
+ * instead of writing `required: false`. The object is where an age limit can enter later.
19
+ *
20
+ * @example
21
+ * const validation: IdentityValidation = { required: true };
22
+ */
23
+ export const IdentityValidationSchema = /* @__PURE__ */ v.strictObject({ required: v.literal(true) });
24
+ /**
25
+ * `identity` Grant Request: read the identity of a Profile or an Organization. Two forms: a Profile
26
+ * (named, or the signed-in one by default) may also ask for its {@link IdentityValidationSchema | validation};
27
+ * an Organization is never validated, so its form has no `validation`.
14
28
  *
15
29
  * @example
16
30
  * const kyb: IdentityGrantRequest = {
@@ -19,20 +33,51 @@ export const PROFILE_ACTIONS = ["update"];
19
33
  * locations: ["https://api.andco.com"],
20
34
  * subject: { type: "organization" },
21
35
  * };
36
+ *
37
+ * @example
38
+ * const validated: IdentityGrantRequest = {
39
+ * type: "identity",
40
+ * actions: ["read"],
41
+ * locations: ["https://api.andco.com"],
42
+ * subject: { type: "profile" },
43
+ * validation: { required: true },
44
+ * };
22
45
  */
23
- export const IdentityGrantRequestSchema = /* @__PURE__ */ v.strictObject({
24
- type: v.literal("identity"),
25
- actions: actionSet(IDENTITY_ACTIONS),
26
- locations: AndcoRarLocationsSchema,
27
- subject: SubjectPickerSchema,
28
- });
29
- /** `identity` Grant. */
30
- export const IdentityGrantSchema = /* @__PURE__ */ v.strictObject({
31
- type: v.literal("identity"),
32
- actions: actionSet(IDENTITY_ACTIONS),
33
- locations: AndcoRarLocationsSchema,
34
- subject: GrantedSubjectSchema,
35
- });
46
+ export const IdentityGrantRequestSchema = /* @__PURE__ */ v.union([
47
+ v.strictObject({
48
+ type: v.literal("identity"),
49
+ actions: actionSet(IDENTITY_ACTIONS),
50
+ locations: AndcoRarLocationsSchema,
51
+ subject: ProfileOnlySubjectPickerSchema,
52
+ validation: v.nullish(IdentityValidationSchema),
53
+ }),
54
+ v.strictObject({
55
+ type: v.literal("identity"),
56
+ actions: actionSet(IDENTITY_ACTIONS),
57
+ locations: AndcoRarLocationsSchema,
58
+ subject: OrganizationSubjectPickerSchema,
59
+ // Never present. Typing the key as `undefined` makes asking an Organization's validation a compile
60
+ // error, not only a runtime one.
61
+ validation: v.optional(v.never()),
62
+ }),
63
+ ]);
64
+ /** `identity` Grant: the two forms with the subject resolved. `validation` stays only when it was asked. */
65
+ export const IdentityGrantSchema = /* @__PURE__ */ v.union([
66
+ v.strictObject({
67
+ type: v.literal("identity"),
68
+ actions: actionSet(IDENTITY_ACTIONS),
69
+ locations: AndcoRarLocationsSchema,
70
+ subject: GrantedProfileSubjectSchema,
71
+ validation: v.optional(IdentityValidationSchema),
72
+ }),
73
+ v.strictObject({
74
+ type: v.literal("identity"),
75
+ actions: actionSet(IDENTITY_ACTIONS),
76
+ locations: AndcoRarLocationsSchema,
77
+ subject: GrantedOrganizationSubjectSchema,
78
+ validation: v.optional(v.never()),
79
+ }),
80
+ ]);
36
81
  /**
37
82
  * `address` Grant Request: read or manage the addresses of a Profile or an Organization.
38
83
  *
@@ -107,21 +152,3 @@ export const ProfileGrantSchema = /* @__PURE__ */ v.strictObject({
107
152
  locations: AndcoRarLocationsSchema,
108
153
  subject: GrantedProfileSubjectSchema,
109
154
  });
110
- const requestJson = (type, actions, subject) => detailTypeJson([detailFormJson(type, actionSetJson(actions), { subject }, [])]);
111
- const grantJson = (type, actions, subject) => detailTypeJson([detailFormJson(type, actionSetJson(actions), { subject }, ["subject"])]);
112
- /** JSON Schema mirror of {@link IdentityGrantRequestSchema}. */
113
- export const IDENTITY_GRANT_REQUEST_JSON_SCHEMA = /* @__PURE__ */ requestJson("identity", IDENTITY_ACTIONS, SUBJECT_PICKER_JSON_SCHEMA);
114
- /** JSON Schema mirror of {@link IdentityGrantSchema}. */
115
- export const IDENTITY_GRANT_JSON_SCHEMA = /* @__PURE__ */ grantJson("identity", IDENTITY_ACTIONS, GRANTED_SUBJECT_JSON_SCHEMA);
116
- /** JSON Schema mirror of {@link AddressGrantRequestSchema}. */
117
- export const ADDRESS_GRANT_REQUEST_JSON_SCHEMA = /* @__PURE__ */ requestJson("address", ADDRESS_ACTIONS, SUBJECT_PICKER_JSON_SCHEMA);
118
- /** JSON Schema mirror of {@link AddressGrantSchema}. */
119
- export const ADDRESS_GRANT_JSON_SCHEMA = /* @__PURE__ */ grantJson("address", ADDRESS_ACTIONS, GRANTED_SUBJECT_JSON_SCHEMA);
120
- /** JSON Schema mirror of {@link OrganizationGrantRequestSchema}. */
121
- export const ORGANIZATION_GRANT_REQUEST_JSON_SCHEMA = /* @__PURE__ */ requestJson("organization", ORGANIZATION_ACTIONS, PROFILE_ONLY_SUBJECT_PICKER_JSON_SCHEMA);
122
- /** JSON Schema mirror of {@link OrganizationGrantSchema}. */
123
- export const ORGANIZATION_GRANT_JSON_SCHEMA = /* @__PURE__ */ grantJson("organization", ORGANIZATION_ACTIONS, GRANTED_PROFILE_SUBJECT_JSON_SCHEMA);
124
- /** JSON Schema mirror of {@link ProfileGrantRequestSchema}. */
125
- export const PROFILE_GRANT_REQUEST_JSON_SCHEMA = /* @__PURE__ */ requestJson("profile", PROFILE_ACTIONS, PROFILE_ONLY_SUBJECT_PICKER_JSON_SCHEMA);
126
- /** JSON Schema mirror of {@link ProfileGrantSchema}. */
127
- export const PROFILE_GRANT_JSON_SCHEMA = /* @__PURE__ */ grantJson("profile", PROFILE_ACTIONS, GRANTED_PROFILE_SUBJECT_JSON_SCHEMA);