@andco/protocol 0.0.11 → 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.
- package/dist/api-errors.d.ts +5 -128
- package/dist/api-errors.d.ts.map +1 -1
- package/dist/api-errors.js +5 -131
- package/dist/authorization-preparation.d.ts +3 -3
- package/dist/authorization-preparation.d.ts.map +1 -1
- package/dist/authorization-preparation.js +4 -0
- package/dist/authorization.js +2 -2
- package/dist/errors.d.ts +52 -16
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +52 -12
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/intent-input.d.ts +1791 -725
- package/dist/intent-input.d.ts.map +1 -1
- package/dist/intent-input.js +325 -157
- package/dist/issues.d.ts +61 -0
- package/dist/issues.d.ts.map +1 -0
- package/dist/issues.js +61 -0
- package/dist/messages/index.d.ts +2 -2
- package/dist/messages/index.d.ts.map +1 -1
- package/dist/messages/index.js +10 -3
- package/dist/messages/set-preferences.d.ts +13 -1
- package/dist/messages/set-preferences.d.ts.map +1 -1
- package/dist/messages/set-preferences.js +31 -9
- package/dist/miniapp-manifest.d.ts +2 -2
- package/dist/miniapp-manifest.d.ts.map +1 -1
- package/dist/miniapp-manifest.js +1 -1
- package/dist/native-intent.d.ts +48 -28
- package/dist/native-intent.d.ts.map +1 -1
- package/dist/native-intent.js +76 -24
- package/dist/pagination.d.ts +37 -31
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +72 -24
- package/dist/rar/account-matchers.d.ts +47 -240
- package/dist/rar/account-matchers.d.ts.map +1 -1
- package/dist/rar/account-matchers.js +52 -131
- package/dist/rar/bank.d.ts +280 -392
- package/dist/rar/bank.d.ts.map +1 -1
- package/dist/rar/bank.js +68 -137
- package/dist/rar/catalog.d.ts +305 -288
- package/dist/rar/catalog.d.ts.map +1 -1
- package/dist/rar/catalog.js +69 -29
- package/dist/rar/detail.d.ts +15 -32
- package/dist/rar/detail.d.ts.map +1 -1
- package/dist/rar/detail.js +14 -34
- package/dist/rar/index.d.ts +2 -1
- package/dist/rar/index.d.ts.map +1 -1
- package/dist/rar/index.js +2 -1
- package/dist/rar/json-schemas.generated.d.ts +4 -0
- package/dist/rar/json-schemas.generated.d.ts.map +1 -0
- package/dist/rar/json-schemas.generated.js +3570 -0
- package/dist/rar/money.d.ts +5 -5
- package/dist/rar/money.d.ts.map +1 -1
- package/dist/rar/money.js +5 -5
- package/dist/rar/project-users.d.ts +40 -14
- package/dist/rar/project-users.d.ts.map +1 -1
- package/dist/rar/project-users.js +20 -23
- package/dist/rar/subject-data.d.ts +96 -48
- package/dist/rar/subject-data.d.ts.map +1 -1
- package/dist/rar/subject-data.js +61 -34
- package/dist/rar/subject.d.ts +18 -85
- package/dist/rar/subject.d.ts.map +1 -1
- package/dist/rar/subject.js +23 -51
- package/dist/rest/accounts.d.ts +347 -0
- package/dist/rest/accounts.d.ts.map +1 -0
- package/dist/rest/accounts.js +108 -0
- package/dist/rest/addresses.d.ts +581 -0
- package/dist/rest/addresses.d.ts.map +1 -0
- package/dist/rest/addresses.js +190 -0
- package/dist/rest/api-error.d.ts +104 -0
- package/dist/rest/api-error.d.ts.map +1 -0
- package/dist/rest/api-error.js +103 -0
- package/dist/rest/authorization.d.ts +123 -0
- package/dist/rest/authorization.d.ts.map +1 -0
- package/dist/rest/authorization.js +62 -0
- package/dist/rest/catalog.d.ts +199 -0
- package/dist/rest/catalog.d.ts.map +1 -0
- package/dist/rest/catalog.js +63 -0
- package/dist/rest/common.d.ts +637 -0
- package/dist/rest/common.d.ts.map +1 -0
- package/dist/rest/common.js +172 -0
- package/dist/rest/contract.d.ts +3480 -0
- package/dist/rest/contract.d.ts.map +1 -0
- package/dist/rest/contract.js +120 -0
- package/dist/rest/events.d.ts +145 -0
- package/dist/rest/events.d.ts.map +1 -0
- package/dist/rest/events.js +42 -0
- package/dist/rest/http.d.ts +49 -0
- package/dist/rest/http.d.ts.map +1 -0
- package/dist/rest/http.js +25 -0
- package/dist/rest/identity.d.ts +627 -0
- package/dist/rest/identity.d.ts.map +1 -0
- package/dist/rest/identity.js +128 -0
- package/dist/rest/index.d.ts +14 -0
- package/dist/rest/index.d.ts.map +1 -0
- package/dist/rest/index.js +13 -0
- package/dist/rest/intents.d.ts +4556 -0
- package/dist/rest/intents.d.ts.map +1 -0
- package/dist/rest/intents.js +551 -0
- package/dist/rest/signatures.d.ts +110 -0
- package/dist/rest/signatures.d.ts.map +1 -0
- package/dist/rest/signatures.js +113 -0
- package/dist/rest/subjects.d.ts +14 -0
- package/dist/rest/subjects.d.ts.map +1 -0
- package/dist/rest/subjects.js +22 -0
- package/dist/service-grants.d.ts +2 -2
- package/dist/service-grants.d.ts.map +1 -1
- package/dist/service-grants.js +1 -1
- package/dist/transport/generated/oauth-api.d.ts +5547 -1448
- package/dist/transport/generated/oauth-api.d.ts.map +1 -1
- package/dist/transport/intents.d.ts +9 -134
- package/dist/transport/intents.d.ts.map +1 -1
- package/dist/transport/intents.js +21 -405
- package/dist/transport/rest.d.ts +15 -5
- package/dist/transport/rest.d.ts.map +1 -1
- package/dist/userinfo.d.ts +22 -9
- package/dist/userinfo.d.ts.map +1 -1
- package/dist/userinfo.js +17 -12
- package/package.json +13 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/rar/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/rar/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,KAAK,KAAK,EAAsB,MAAM,cAAc,CAAC;AAwC9D,0EAA0E;AAC1E,eAAO,MAAM,eAA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,CAAC,YAAY,CAAC,CAAC;AAEhB,6FAA6F;AAC7F,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAEtE;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,eAAe;IAChD,SAAgB,IAAI,EAAE,iBAAiB,CAAC;IACxC,SAAgB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,SAAgB,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;gBAGvC,IAAI,EAAE,iBAAiB,EACvB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,MAAM,GAAE,SAAS,KAAK,EAAO,EAC7B,OAAO,CAAC,EAAE,YAAY;CAOzB;AAED,wDAAwD;AACxD,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,YAAY,CAElE;AAED,iEAAiE;AACjE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,oBAAoB,CAElF;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,IAAI,UAAU,CAEpF;AA+BD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,iBAAiB,GAAG,UAAU,GAAG,KAAK,EAAE,CAsB9E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,iBAAiB,CAEzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,UAAU,CAE3D"}
|
package/dist/rar/catalog.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import { ANDCO_API_ERROR_CODES } from "../api-errors.js";
|
|
3
2
|
import { ErrorExtendable } from "../errors.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { issuesAt, issuesOf } from "../issues.js";
|
|
4
|
+
import { accountMatcherListIssues } from "./account-matchers.js";
|
|
5
|
+
import { amountRangeIssues, BANK_ACCOUNT_ACTIONS, BANK_DEPOSIT_ACTIONS, BANK_TRANSACTION_ACTIONS, BANK_TRANSFER_ACTIONS, BankAccountGrantRequestSchema, BankAccountGrantSchema, BankDepositGrantRequestSchema, BankDepositGrantSchema, BankTransactionGrantRequestSchema, BankTransactionGrantSchema, BankTransferGrantRequestSchema, BankTransferGrantSchema, } from "./bank.js";
|
|
6
|
+
import { actionSetIssues } from "./detail.js";
|
|
7
|
+
import { PROJECT_USERS_ACTIONS, ProjectUsersGrantRequestSchema, ProjectUsersGrantSchema, projectUsersIssues, } from "./project-users.js";
|
|
8
|
+
import { subjectIssues } from "./subject.js";
|
|
9
|
+
import { ADDRESS_ACTIONS, AddressGrantRequestSchema, AddressGrantSchema, IDENTITY_ACTIONS, IdentityGrantRequestSchema, IdentityGrantSchema, ORGANIZATION_ACTIONS, OrganizationGrantRequestSchema, OrganizationGrantSchema, PROFILE_ACTIONS, ProfileGrantRequestSchema, ProfileGrantSchema, } from "./subject-data.js";
|
|
7
10
|
/** Every authorization detail type Andco's Resource Server implements. */
|
|
8
11
|
export const ANDCO_RAR_TYPES = [
|
|
9
12
|
"bank_account",
|
|
@@ -22,76 +25,60 @@ export const ANDCO_RAR_TYPES = [
|
|
|
22
25
|
*/
|
|
23
26
|
export const ANDCO_RESERVED_RAR_TYPES = ["bank_beneficiaries", "identity_documents"];
|
|
24
27
|
/**
|
|
25
|
-
* The whole Andco authorization detail catalog, keyed by type. The gate's seeds store
|
|
26
|
-
*
|
|
27
|
-
* a guard test compares them
|
|
28
|
+
* The whole Andco authorization detail catalog, keyed by type. The gate's seeds store `actions` as
|
|
29
|
+
* each type's registered actions and, as its request schema, the JSON Schema `ANDCO_RAR_JSON_SCHEMAS`
|
|
30
|
+
* holds, generated from `grantRequest`; a guard test compares them. The schemas describe shape only:
|
|
31
|
+
* the rules JSON Schema cannot say are {@link andcoRarIssues}, which the parse functions apply and
|
|
32
|
+
* the gate's SQL repeats.
|
|
28
33
|
*
|
|
29
34
|
* @example
|
|
30
|
-
* const {
|
|
35
|
+
* const { grantRequest, actions } = ANDCO_RAR_CATALOG.bank_transfer;
|
|
31
36
|
*/
|
|
32
37
|
export const ANDCO_RAR_CATALOG = {
|
|
33
38
|
bank_account: {
|
|
34
39
|
actions: BANK_ACCOUNT_ACTIONS,
|
|
35
40
|
grantRequest: BankAccountGrantRequestSchema,
|
|
36
41
|
grant: BankAccountGrantSchema,
|
|
37
|
-
grantRequestJsonSchema: BANK_ACCOUNT_GRANT_REQUEST_JSON_SCHEMA,
|
|
38
|
-
grantJsonSchema: BANK_ACCOUNT_GRANT_JSON_SCHEMA,
|
|
39
42
|
},
|
|
40
43
|
bank_transaction: {
|
|
41
44
|
actions: BANK_TRANSACTION_ACTIONS,
|
|
42
45
|
grantRequest: BankTransactionGrantRequestSchema,
|
|
43
46
|
grant: BankTransactionGrantSchema,
|
|
44
|
-
grantRequestJsonSchema: BANK_TRANSACTION_GRANT_REQUEST_JSON_SCHEMA,
|
|
45
|
-
grantJsonSchema: BANK_TRANSACTION_GRANT_JSON_SCHEMA,
|
|
46
47
|
},
|
|
47
48
|
bank_transfer: {
|
|
48
49
|
actions: BANK_TRANSFER_ACTIONS,
|
|
49
50
|
grantRequest: BankTransferGrantRequestSchema,
|
|
50
51
|
grant: BankTransferGrantSchema,
|
|
51
|
-
grantRequestJsonSchema: BANK_TRANSFER_GRANT_REQUEST_JSON_SCHEMA,
|
|
52
|
-
grantJsonSchema: BANK_TRANSFER_GRANT_JSON_SCHEMA,
|
|
53
52
|
},
|
|
54
53
|
bank_deposit: {
|
|
55
54
|
actions: BANK_DEPOSIT_ACTIONS,
|
|
56
55
|
grantRequest: BankDepositGrantRequestSchema,
|
|
57
56
|
grant: BankDepositGrantSchema,
|
|
58
|
-
grantRequestJsonSchema: BANK_DEPOSIT_GRANT_REQUEST_JSON_SCHEMA,
|
|
59
|
-
grantJsonSchema: BANK_DEPOSIT_GRANT_JSON_SCHEMA,
|
|
60
57
|
},
|
|
61
58
|
identity: {
|
|
62
59
|
actions: IDENTITY_ACTIONS,
|
|
63
60
|
grantRequest: IdentityGrantRequestSchema,
|
|
64
61
|
grant: IdentityGrantSchema,
|
|
65
|
-
grantRequestJsonSchema: IDENTITY_GRANT_REQUEST_JSON_SCHEMA,
|
|
66
|
-
grantJsonSchema: IDENTITY_GRANT_JSON_SCHEMA,
|
|
67
62
|
},
|
|
68
63
|
address: {
|
|
69
64
|
actions: ADDRESS_ACTIONS,
|
|
70
65
|
grantRequest: AddressGrantRequestSchema,
|
|
71
66
|
grant: AddressGrantSchema,
|
|
72
|
-
grantRequestJsonSchema: ADDRESS_GRANT_REQUEST_JSON_SCHEMA,
|
|
73
|
-
grantJsonSchema: ADDRESS_GRANT_JSON_SCHEMA,
|
|
74
67
|
},
|
|
75
68
|
organization: {
|
|
76
69
|
actions: ORGANIZATION_ACTIONS,
|
|
77
70
|
grantRequest: OrganizationGrantRequestSchema,
|
|
78
71
|
grant: OrganizationGrantSchema,
|
|
79
|
-
grantRequestJsonSchema: ORGANIZATION_GRANT_REQUEST_JSON_SCHEMA,
|
|
80
|
-
grantJsonSchema: ORGANIZATION_GRANT_JSON_SCHEMA,
|
|
81
72
|
},
|
|
82
73
|
profile: {
|
|
83
74
|
actions: PROFILE_ACTIONS,
|
|
84
75
|
grantRequest: ProfileGrantRequestSchema,
|
|
85
76
|
grant: ProfileGrantSchema,
|
|
86
|
-
grantRequestJsonSchema: PROFILE_GRANT_REQUEST_JSON_SCHEMA,
|
|
87
|
-
grantJsonSchema: PROFILE_GRANT_JSON_SCHEMA,
|
|
88
77
|
},
|
|
89
78
|
project_users: {
|
|
90
79
|
actions: PROJECT_USERS_ACTIONS,
|
|
91
80
|
grantRequest: ProjectUsersGrantRequestSchema,
|
|
92
81
|
grant: ProjectUsersGrantSchema,
|
|
93
|
-
grantRequestJsonSchema: PROJECT_USERS_GRANT_REQUEST_JSON_SCHEMA,
|
|
94
|
-
grantJsonSchema: PROJECT_USERS_GRANT_JSON_SCHEMA,
|
|
95
82
|
},
|
|
96
83
|
};
|
|
97
84
|
/**
|
|
@@ -139,19 +126,72 @@ function parseForm(detail, form, caller) {
|
|
|
139
126
|
const type = typeOf(detail);
|
|
140
127
|
if (isAndcoReservedRarType(type)) {
|
|
141
128
|
console.debug("[%s] reserved type %s is not implemented", caller, type);
|
|
142
|
-
throw new AndcoRarError(
|
|
129
|
+
throw new AndcoRarError("not_implemented", type);
|
|
143
130
|
}
|
|
144
131
|
if (!isAndcoRarType(type)) {
|
|
145
132
|
console.debug("[%s] unknown authorization detail type %o", caller, type);
|
|
146
|
-
throw new AndcoRarError(
|
|
133
|
+
throw new AndcoRarError("invalid_request", type);
|
|
147
134
|
}
|
|
148
135
|
const result = v.safeParse(ANDCO_RAR_CATALOG[type][form], detail);
|
|
149
136
|
if (!result.success) {
|
|
150
137
|
console.debug("[%s] %s does not satisfy its contract %o", caller, type, v.flatten(result.issues));
|
|
151
|
-
throw new AndcoRarError(
|
|
138
|
+
throw new AndcoRarError("invalid_request", type, issuesOf(result.issues));
|
|
139
|
+
}
|
|
140
|
+
const issues = andcoRarIssues(result.output);
|
|
141
|
+
if (issues.length > 0) {
|
|
142
|
+
console.debug("[%s] %s breaks the rules of its type %o", caller, type, issues);
|
|
143
|
+
throw new AndcoRarError("invalid_request", type, issues);
|
|
152
144
|
}
|
|
153
145
|
return result.output;
|
|
154
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* The rules of an Andco authorization detail that already matches its schema, in either form: what
|
|
149
|
+
* JSON Schema cannot say, each answered as an {@link Issue} with its code in `type`.
|
|
150
|
+
*
|
|
151
|
+
* - `duplicate_action` at an action listed twice.
|
|
152
|
+
* - `identifier_exceeds_organization_id` at an Organization `subject.identifier` above the `int4`
|
|
153
|
+
* ceiling ({@link subjectIssues}).
|
|
154
|
+
* - `duplicate_account_matcher`, `account_selection_incoherent` and `account_selection_not_pickable`
|
|
155
|
+
* in `accounts`, `sources` and `destinations` ({@link accountMatcherListIssues}); only a Transfer's
|
|
156
|
+
* destinations are a list nobody picks from.
|
|
157
|
+
* - `minimum_above_maximum` in `transactions` ({@link amountRangeIssues}).
|
|
158
|
+
* - `duplicate_identifier` and `duplicate_field` in a `project_users` detail ({@link projectUsersIssues}).
|
|
159
|
+
*
|
|
160
|
+
* {@link parseAndcoGrantRequest} and {@link parseAndcoGrant} apply them after the schema.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* andcoRarIssues({
|
|
164
|
+
* type: "bank_transfer",
|
|
165
|
+
* actions: ["create"],
|
|
166
|
+
* locations: ["https://api.andco.com"],
|
|
167
|
+
* destinations: [{ type: "any", limit: "all" }],
|
|
168
|
+
* currency: "CLP",
|
|
169
|
+
* transactions: { minimum: "50000", maximum: "1000" },
|
|
170
|
+
* }); // [{ type: "minimum_above_maximum", path: [{ key: "transactions" }, { key: "minimum" }] }]
|
|
171
|
+
*/
|
|
172
|
+
export function andcoRarIssues(detail) {
|
|
173
|
+
const issues = issuesAt(["actions"], actionSetIssues(detail.actions));
|
|
174
|
+
if ("subject" in detail) {
|
|
175
|
+
issues.push(...issuesAt(["subject"], subjectIssues(detail.subject)));
|
|
176
|
+
}
|
|
177
|
+
if ("accounts" in detail && detail.accounts) {
|
|
178
|
+
issues.push(...issuesAt(["accounts"], accountMatcherListIssues(detail.accounts, { pickable: true })));
|
|
179
|
+
}
|
|
180
|
+
if ("sources" in detail && detail.sources) {
|
|
181
|
+
issues.push(...issuesAt(["sources"], accountMatcherListIssues(detail.sources, { pickable: true })));
|
|
182
|
+
}
|
|
183
|
+
if ("destinations" in detail && detail.destinations) {
|
|
184
|
+
const pickable = detail.type === "bank_deposit";
|
|
185
|
+
issues.push(...issuesAt(["destinations"], accountMatcherListIssues(detail.destinations, { pickable })));
|
|
186
|
+
}
|
|
187
|
+
if ("transactions" in detail && detail.transactions) {
|
|
188
|
+
issues.push(...issuesAt(["transactions"], amountRangeIssues(detail.transactions)));
|
|
189
|
+
}
|
|
190
|
+
if (detail.type === "project_users") {
|
|
191
|
+
issues.push(...projectUsersIssues(detail));
|
|
192
|
+
}
|
|
193
|
+
return issues;
|
|
194
|
+
}
|
|
155
195
|
/**
|
|
156
196
|
* Validates one Andco authorization detail in its Grant Request form, dispatching on `type`.
|
|
157
197
|
* Throws {@link AndcoRarError}: `not_implemented` for a reserved type, `invalid_request` otherwise.
|
package/dist/rar/detail.d.ts
CHANGED
|
@@ -1,39 +1,22 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
+
import { type Issue } from "../issues.js";
|
|
2
3
|
/** The `locations` every Andco authorization detail carries: Andco's Resource Server, alone. */
|
|
3
4
|
export declare const ANDCO_RAR_LOCATIONS: readonly ["https://api.andco.com"];
|
|
4
5
|
/** Valibot schema of {@link ANDCO_RAR_LOCATIONS}. */
|
|
5
|
-
export declare const AndcoRarLocationsSchema: v.
|
|
6
|
-
/** A non-empty list of distinct actions drawn from `options`. Throws an error if the list is empty or contains duplicates. */
|
|
7
|
-
export declare function actionSet<const Options extends readonly [string, ...string[]]>(options: Options): v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<Options, undefined>, undefined>, v.MinLengthAction<Options[number][], 1, undefined>, v.CheckAction<Options[number][], "duplicate_action">]>;
|
|
8
|
-
/** Wraps a JSON Schema so that `null` is also accepted, the JSON form of valibot's `nullish`. */
|
|
9
|
-
export declare function nullableJson<Schema extends object>(schema: Schema): {
|
|
10
|
-
anyOf: (Schema | {
|
|
11
|
-
type: string;
|
|
12
|
-
})[];
|
|
13
|
-
};
|
|
14
|
-
/** JSON Schema mirror of {@link actionSet}. */
|
|
15
|
-
export declare function actionSetJson(options: readonly string[]): {
|
|
16
|
-
type: string;
|
|
17
|
-
minItems: number;
|
|
18
|
-
uniqueItems: boolean;
|
|
19
|
-
items: {
|
|
20
|
-
enum: string[];
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
/** JSON Schema mirror of {@link AndcoRarLocationsSchema}. */
|
|
24
|
-
export declare const ANDCO_RAR_LOCATIONS_JSON_SCHEMA: {
|
|
25
|
-
type: string;
|
|
26
|
-
minItems: number;
|
|
27
|
-
maxItems: number;
|
|
28
|
-
items: {
|
|
29
|
-
const: "https://api.andco.com";
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
/** One form of an authorization detail as a closed JSON Schema object. */
|
|
33
|
-
export declare function detailFormJson(type: string, actions: object, properties: Record<string, object>, required: readonly string[]): Record<string, unknown>;
|
|
6
|
+
export declare const AndcoRarLocationsSchema: v.StrictTupleSchema<[v.LiteralSchema<"https://api.andco.com", undefined>], undefined>;
|
|
34
7
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
8
|
+
* A non-empty list of actions drawn from `options`. That they are distinct is shape in JSON Schema
|
|
9
|
+
* (`uniqueItems`, written through `v.metadata`) and the rule {@link actionSetIssues} in TypeScript,
|
|
10
|
+
* since Valibot has no action for it.
|
|
37
11
|
*/
|
|
38
|
-
export declare function
|
|
12
|
+
export declare function actionSet<const Options extends readonly [string, ...string[]]>(options: Options): v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<Options, undefined>, undefined>, v.MinLengthAction<Options[number][], 1, undefined>, v.MetadataAction<Options[number][], {
|
|
13
|
+
readonly uniqueItems: true;
|
|
14
|
+
}>]>;
|
|
15
|
+
/**
|
|
16
|
+
* The rule of an {@link actionSet}: `duplicate_action` at every action listed twice.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* actionSetIssues(["read", "read"]); // [{ type: "duplicate_action", path: [{ key: 1 }] }]
|
|
20
|
+
*/
|
|
21
|
+
export declare function actionSetIssues(actions: readonly string[]): Issue[];
|
|
39
22
|
//# sourceMappingURL=detail.d.ts.map
|
package/dist/rar/detail.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detail.d.ts","sourceRoot":"","sources":["../../src/rar/detail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"detail.d.ts","sourceRoot":"","sources":["../../src/rar/detail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAmB,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAE3D,gGAAgG;AAChG,eAAO,MAAM,mBAAmB,oCAA8B,CAAC;AAE/D,qDAAqD;AACrD,eAAO,MAAM,uBAAuB,uFAA+D,CAAC;AAEpG;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,CAAC,OAAO,SAAS,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO;;KAE/F;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,EAAE,CAEnE"}
|
package/dist/rar/detail.js
CHANGED
|
@@ -1,44 +1,24 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { ANDCO_API_ORIGIN } from "../constants.js";
|
|
3
|
+
import { duplicateIssues } from "../issues.js";
|
|
3
4
|
/** The `locations` every Andco authorization detail carries: Andco's Resource Server, alone. */
|
|
4
5
|
export const ANDCO_RAR_LOCATIONS = [ANDCO_API_ORIGIN];
|
|
5
6
|
/** Valibot schema of {@link ANDCO_RAR_LOCATIONS}. */
|
|
6
|
-
export const AndcoRarLocationsSchema = /* @__PURE__ */ v.
|
|
7
|
-
/**
|
|
7
|
+
export const AndcoRarLocationsSchema = /* @__PURE__ */ v.strictTuple([v.literal(ANDCO_API_ORIGIN)]);
|
|
8
|
+
/**
|
|
9
|
+
* A non-empty list of actions drawn from `options`. That they are distinct is shape in JSON Schema
|
|
10
|
+
* (`uniqueItems`, written through `v.metadata`) and the rule {@link actionSetIssues} in TypeScript,
|
|
11
|
+
* since Valibot has no action for it.
|
|
12
|
+
*/
|
|
8
13
|
export function actionSet(options) {
|
|
9
|
-
return v.pipe(v.array(v.picklist(options)), v.minLength(1), v.
|
|
10
|
-
}
|
|
11
|
-
/** Wraps a JSON Schema so that `null` is also accepted, the JSON form of valibot's `nullish`. */
|
|
12
|
-
export function nullableJson(schema) {
|
|
13
|
-
return { anyOf: [{ type: "null" }, schema] };
|
|
14
|
-
}
|
|
15
|
-
/** JSON Schema mirror of {@link actionSet}. */
|
|
16
|
-
export function actionSetJson(options) {
|
|
17
|
-
return { type: "array", minItems: 1, uniqueItems: true, items: { enum: [...options] } };
|
|
18
|
-
}
|
|
19
|
-
/** JSON Schema mirror of {@link AndcoRarLocationsSchema}. */
|
|
20
|
-
export const ANDCO_RAR_LOCATIONS_JSON_SCHEMA = {
|
|
21
|
-
type: "array",
|
|
22
|
-
minItems: 1,
|
|
23
|
-
maxItems: 1,
|
|
24
|
-
items: { const: ANDCO_API_ORIGIN },
|
|
25
|
-
};
|
|
26
|
-
/** One form of an authorization detail as a closed JSON Schema object. */
|
|
27
|
-
export function detailFormJson(type, actions, properties, required) {
|
|
28
|
-
return {
|
|
29
|
-
type: "object",
|
|
30
|
-
additionalProperties: false,
|
|
31
|
-
required: ["type", "actions", "locations", ...required],
|
|
32
|
-
properties: { type: { const: type }, actions, locations: ANDCO_RAR_LOCATIONS_JSON_SCHEMA, ...properties },
|
|
33
|
-
};
|
|
14
|
+
return v.pipe(v.array(v.picklist(options)), v.minLength(1), v.metadata({ uniqueItems: true }));
|
|
34
15
|
}
|
|
35
16
|
/**
|
|
36
|
-
* The
|
|
37
|
-
*
|
|
17
|
+
* The rule of an {@link actionSet}: `duplicate_action` at every action listed twice.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* actionSetIssues(["read", "read"]); // [{ type: "duplicate_action", path: [{ key: 1 }] }]
|
|
38
21
|
*/
|
|
39
|
-
export function
|
|
40
|
-
|
|
41
|
-
if (forms.length === 1 && only !== undefined)
|
|
42
|
-
return { $schema: "http://json-schema.org/draft-07/schema#", ...only };
|
|
43
|
-
return { $schema: "http://json-schema.org/draft-07/schema#", anyOf: forms };
|
|
22
|
+
export function actionSetIssues(actions) {
|
|
23
|
+
return duplicateIssues(actions, "duplicate_action");
|
|
44
24
|
}
|
package/dist/rar/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from "./account-matchers.js";
|
|
2
2
|
export * from "./bank.js";
|
|
3
3
|
export * from "./catalog.js";
|
|
4
|
-
export { ANDCO_RAR_LOCATIONS, AndcoRarLocationsSchema } from "./detail.js";
|
|
4
|
+
export { ANDCO_RAR_LOCATIONS, AndcoRarLocationsSchema, actionSetIssues } from "./detail.js";
|
|
5
|
+
export * from "./json-schemas.generated.js";
|
|
5
6
|
export * from "./money.js";
|
|
6
7
|
export * from "./project-users.js";
|
|
7
8
|
export * from "./subject.js";
|
package/dist/rar/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rar/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rar/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC5F,cAAc,6BAA6B,CAAC;AAC5C,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
|
package/dist/rar/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from "./account-matchers.js";
|
|
2
2
|
export * from "./bank.js";
|
|
3
3
|
export * from "./catalog.js";
|
|
4
|
-
export { ANDCO_RAR_LOCATIONS, AndcoRarLocationsSchema } from "./detail.js";
|
|
4
|
+
export { ANDCO_RAR_LOCATIONS, AndcoRarLocationsSchema, actionSetIssues } from "./detail.js";
|
|
5
|
+
export * from "./json-schemas.generated.js";
|
|
5
6
|
export * from "./money.js";
|
|
6
7
|
export * from "./project-users.js";
|
|
7
8
|
export * from "./subject.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schemas.generated.d.ts","sourceRoot":"","sources":["../../src/rar/json-schemas.generated.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,wFAAwF;AACxF,eAAO,MAAM,sBAAsB,EAAE,mBAg/GpC,CAAC"}
|