@go-mondo/identity-sdk 0.0.2-beta.39 → 0.0.2-beta.40
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/.release-please-manifest.json +1 -1
- package/.tsbuildinfo/cjs.json +1 -1
- package/.tsbuildinfo/esm.json +1 -1
- package/CHANGELOG.md +7 -0
- package/dist/cjs/app/authorization/resources.js +1 -1
- package/dist/cjs/app/oauth/resources.js +1 -1
- package/dist/cjs/app/oidc/resources.js +2 -2
- package/dist/cjs/app/registration/resources.js +1 -1
- package/dist/cjs/app/resources.js +2 -2
- package/dist/cjs/app/saml/resources.js +2 -2
- package/dist/cjs/association/resources.js +1 -1
- package/dist/cjs/association/schema.d.ts +53 -9
- package/dist/cjs/association/schema.d.ts.map +1 -1
- package/dist/cjs/association/schema.js +8 -9
- package/dist/cjs/association/schema.test.js +1 -50
- package/dist/cjs/authentication/settings/resources.js +1 -1
- package/dist/cjs/authentication/strategies/resources.js +2 -2
- package/dist/cjs/authorization/permissions/resources.js +2 -2
- package/dist/cjs/authorization/roles/resources.js +2 -2
- package/dist/cjs/common/resources/operations.d.ts +3 -2
- package/dist/cjs/common/resources/operations.d.ts.map +1 -1
- package/dist/cjs/common/resources/operations.js +15 -8
- package/dist/cjs/common/resources/operations.test.js +15 -15
- package/dist/cjs/customer/users/resources.js +2 -2
- package/dist/esm/app/authorization/resources.js +2 -2
- package/dist/esm/app/oauth/resources.js +2 -2
- package/dist/esm/app/oidc/resources.js +3 -3
- package/dist/esm/app/registration/resources.js +2 -2
- package/dist/esm/app/resources.js +3 -3
- package/dist/esm/app/saml/resources.js +3 -3
- package/dist/esm/association/resources.js +2 -2
- package/dist/esm/association/schema.d.ts +53 -9
- package/dist/esm/association/schema.d.ts.map +1 -1
- package/dist/esm/association/schema.js +3 -4
- package/dist/esm/association/schema.test.js +2 -51
- package/dist/esm/authentication/settings/resources.js +2 -2
- package/dist/esm/authentication/strategies/resources.js +3 -3
- package/dist/esm/authorization/permissions/resources.js +3 -3
- package/dist/esm/authorization/roles/resources.js +3 -3
- package/dist/esm/common/resources/operations.d.ts +3 -2
- package/dist/esm/common/resources/operations.d.ts.map +1 -1
- package/dist/esm/common/resources/operations.js +12 -6
- package/dist/esm/common/resources/operations.test.js +16 -16
- package/dist/esm/customer/users/resources.js +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-beta.40](https://github.com/go-mondo/identity-node-sdk/compare/identity-sdk-v0.0.2-beta.39...identity-sdk-v0.0.2-beta.40) (2025-11-20)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* association schema ([05bc928](https://github.com/go-mondo/identity-node-sdk/commit/05bc9287d992e6533038045cee376b1dfd36df13))
|
|
9
|
+
|
|
3
10
|
## [0.0.2-beta.39](https://github.com/go-mondo/identity-node-sdk/compare/identity-sdk-v0.0.2-beta.38...identity-sdk-v0.0.2-beta.39) (2025-11-01)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -27,5 +27,5 @@ async function getAuthorization(instance, appId) {
|
|
|
27
27
|
return schema_js_1.AuthorizationSchema.parse(await (0, operations_js_1.getItemWithAuthorization)(new URL(AuthorizationResources.buildPath(appId), instance.config.host), instance.authorizer));
|
|
28
28
|
}
|
|
29
29
|
async function upsertAuthorization(instance, appId, item) {
|
|
30
|
-
return schema_js_1.AuthorizationSchema.parse(await (0, operations_js_1.
|
|
30
|
+
return schema_js_1.AuthorizationSchema.parse(await (0, operations_js_1.putItemWithAuthorization)(new URL(AuthorizationResources.buildPath(appId), instance.config.host), instance.authorizer, schema_js_1.UpsertAuthorizationPayloadSchema.parse(item)));
|
|
31
31
|
}
|
|
@@ -30,5 +30,5 @@ async function getOAuth(instance, appId) {
|
|
|
30
30
|
return schema_js_1.OAuthSchema.parse(await (0, operations_js_1.getItemWithAuthorization)(new URL(OAuthResources.buildPath(appId), instance.config.host), instance.authorizer));
|
|
31
31
|
}
|
|
32
32
|
async function rotateOAuthSecret(instance, appId, item) {
|
|
33
|
-
return schema_js_1.OAuthSchema.parse(await (0, operations_js_1.
|
|
33
|
+
return schema_js_1.OAuthSchema.parse(await (0, operations_js_1.postItemWithAuthorization)(new URL(OAuthResources.buildPath(appId), instance.config.host), instance.authorizer, schema_js_1.InsertOAuthPayloadSchema.parse(item)));
|
|
34
34
|
}
|
|
@@ -38,10 +38,10 @@ async function getOIDC(instance, appId) {
|
|
|
38
38
|
return schema_js_1.OIDCSchema.parse(await (0, operations_js_1.getItemWithAuthorization)(new URL(OIDCResources.buildPath(appId), instance.config.host), instance.authorizer));
|
|
39
39
|
}
|
|
40
40
|
async function insertOIDC(instance, appId, item) {
|
|
41
|
-
return schema_js_1.OIDCSchema.parse(await (0, operations_js_1.
|
|
41
|
+
return schema_js_1.OIDCSchema.parse(await (0, operations_js_1.postItemWithAuthorization)(new URL(OIDCResources.buildPath(appId), instance.config.host), instance.authorizer, item ? schema_js_1.InsertOIDCPayloadSchema.parse(item) : undefined));
|
|
42
42
|
}
|
|
43
43
|
async function updateOIDC(instance, appId, item) {
|
|
44
|
-
return schema_js_1.OIDCSchema.parse(await (0, operations_js_1.
|
|
44
|
+
return schema_js_1.OIDCSchema.parse(await (0, operations_js_1.patchItemWithAuthorization)(new URL(OIDCResources.buildPath(appId), instance.config.host), instance.authorizer, schema_js_1.UpdateOIDCPayloadSchema.parse(item)));
|
|
45
45
|
}
|
|
46
46
|
async function deleteOIDC(instance, appId) {
|
|
47
47
|
return schema_js_1.OIDCSchema.parse(await (0, operations_js_1.deleteItemWithAuthorization)(new URL(OIDCResources.buildPath(appId), instance.config.host), instance.authorizer));
|
|
@@ -30,5 +30,5 @@ async function getRegistration(instance, id) {
|
|
|
30
30
|
return schema_js_1.RegistrationSchema.parse(await (0, operations_js_1.getItemWithAuthorization)(new URL(RegistrationResources.buildPath(id), instance.config.host), instance.authorizer));
|
|
31
31
|
}
|
|
32
32
|
async function upsertRegistration(instance, id, item) {
|
|
33
|
-
return schema_js_1.RegistrationSchema.parse(await (0, operations_js_1.
|
|
33
|
+
return schema_js_1.RegistrationSchema.parse(await (0, operations_js_1.postItemWithAuthorization)(new URL(RegistrationResources.buildPath(id), instance.config.host), instance.authorizer, schema_js_1.UpsertRegistrationPayloadSchema.parse(item)));
|
|
34
34
|
}
|
|
@@ -47,10 +47,10 @@ async function getApp(instance, id) {
|
|
|
47
47
|
return schema_js_1.AppSchema.parse(await (0, operations_js_1.getItemWithAuthorization)(new URL(AppResources.buildPath(id), instance.config.host), instance.authorizer));
|
|
48
48
|
}
|
|
49
49
|
async function insertApp(instance, item) {
|
|
50
|
-
return schema_js_1.AppSchema.parse(await (0, operations_js_1.
|
|
50
|
+
return schema_js_1.AppSchema.parse(await (0, operations_js_1.postItemWithAuthorization)(new URL(AppResources.buildPath(), instance.config.host), instance.authorizer, schema_js_1.InsertAppPayloadSchema.parse));
|
|
51
51
|
}
|
|
52
52
|
async function updateApp(instance, id, item) {
|
|
53
|
-
return schema_js_1.AppSchema.parse(await (0, operations_js_1.
|
|
53
|
+
return schema_js_1.AppSchema.parse(await (0, operations_js_1.patchItemWithAuthorization)(new URL(AppResources.buildPath(id), instance.config.host), instance.authorizer, schema_js_1.UpdateAppPayloadSchema.parse(item)));
|
|
54
54
|
}
|
|
55
55
|
async function deleteApp(instance, id) {
|
|
56
56
|
return schema_js_1.AppSchema.parse(await (0, operations_js_1.deleteItemWithAuthorization)(new URL(AppResources.buildPath(id), instance.config.host), instance.authorizer));
|
|
@@ -38,10 +38,10 @@ async function getSAML(instance, appId) {
|
|
|
38
38
|
return schema_js_1.SAMLSchema.parse(await (0, operations_js_1.getItemWithAuthorization)(new URL(SAMLResources.buildPath(appId), instance.config.host), instance.authorizer));
|
|
39
39
|
}
|
|
40
40
|
async function insertSAML(instance, appId, item) {
|
|
41
|
-
return schema_js_1.SAMLSchema.parse(await (0, operations_js_1.
|
|
41
|
+
return schema_js_1.SAMLSchema.parse(await (0, operations_js_1.postItemWithAuthorization)(new URL(SAMLResources.buildPath(appId), instance.config.host), instance.authorizer, item ? schema_js_1.InsertSAMLPayloadSchema.parse(item) : undefined));
|
|
42
42
|
}
|
|
43
43
|
async function updateSAML(instance, appId, item) {
|
|
44
|
-
return schema_js_1.SAMLSchema.parse(await (0, operations_js_1.
|
|
44
|
+
return schema_js_1.SAMLSchema.parse(await (0, operations_js_1.patchItemWithAuthorization)(new URL(SAMLResources.buildPath(appId), instance.config.host), instance.authorizer, schema_js_1.UpdateSAMLPayloadSchema.parse(item)));
|
|
45
45
|
}
|
|
46
46
|
async function deleteSAML(instance, appId) {
|
|
47
47
|
return schema_js_1.SAMLSchema.parse(await (0, operations_js_1.deleteItemWithAuthorization)(new URL(SAMLResources.buildPath(appId), instance.config.host), instance.authorizer));
|
|
@@ -42,7 +42,7 @@ async function listAssociations(instance, id, options, pagination) {
|
|
|
42
42
|
return (0, collection_js_1.PaginationCollectionSchema)(schema_js_1.AssociationSchema).parse(await (0, operations_js_1.getItemWithAuthorization)(url, instance.authorizer));
|
|
43
43
|
}
|
|
44
44
|
async function upsertAssociation(instance, fromId, toId, item) {
|
|
45
|
-
return schema_js_1.AssociationSchema.parse(await (0, operations_js_1.
|
|
45
|
+
return schema_js_1.AssociationSchema.parse(await (0, operations_js_1.putItemWithAuthorization)(new URL(AssociationResources.buildPath(fromId, toId), instance.config.host), instance.authorizer, item ? schema_js_1.UpsertAssociationPayloadSchema.parse(item) : undefined));
|
|
46
46
|
}
|
|
47
47
|
async function deleteAssociation(instance, fromId, toId) {
|
|
48
48
|
return schema_js_1.AssociationSchema.parse(await (0, operations_js_1.deleteItemWithAuthorization)(new URL(AssociationResources.buildPath(fromId, toId), instance.config.host), instance.authorizer));
|
|
@@ -5,17 +5,9 @@ export declare const AssociationObjectType: {
|
|
|
5
5
|
readonly ROLE: "Role";
|
|
6
6
|
readonly APP: "App";
|
|
7
7
|
readonly PERMISSION: "Permission";
|
|
8
|
+
readonly SESSION: "Session";
|
|
8
9
|
};
|
|
9
10
|
export type AnyAssociationObjectType = (typeof AssociationObjectType)[keyof typeof AssociationObjectType];
|
|
10
|
-
export declare const AssociationIdReferenceSchema: z.ZodObject<{
|
|
11
|
-
id: z.ZodString;
|
|
12
|
-
}, z.core.$strip>;
|
|
13
|
-
export type AssociationIdReference = z.output<typeof AssociationIdReferenceSchema>;
|
|
14
|
-
export declare const AssociationAttributesReferenceSchema: z.ZodIntersection<z.ZodObject<{
|
|
15
|
-
id: z.ZodString;
|
|
16
|
-
}, z.core.$strip>, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
17
|
-
export type AssociationAttributesReference = z.output<typeof AssociationAttributesReferenceSchema>;
|
|
18
|
-
export type AssociationReference = AssociationIdReference | AssociationAttributesReference;
|
|
19
11
|
export declare const AssociationObjectSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
20
12
|
status: z.ZodDefault<z.ZodEnum<{
|
|
21
13
|
active: "active";
|
|
@@ -59,6 +51,19 @@ export declare const AssociationObjectSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
59
51
|
}>>;
|
|
60
52
|
model: z.ZodLiteral<"Permission">;
|
|
61
53
|
id: z.ZodString;
|
|
54
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
55
|
+
model: z.ZodLiteral<"Session">;
|
|
56
|
+
createdAt: z.ZodPipe<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>, z.ZodTransform<string, Date>>;
|
|
57
|
+
id: z.ZodString;
|
|
58
|
+
status: z.ZodEnum<{
|
|
59
|
+
pending: "pending";
|
|
60
|
+
initiated: "initiated";
|
|
61
|
+
authenticated: "authenticated";
|
|
62
|
+
}>;
|
|
63
|
+
expiresAt: z.ZodPipe<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>, z.ZodTransform<string, Date>>;
|
|
64
|
+
user: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>>;
|
|
65
|
+
userAgent: z.ZodOptional<z.ZodString>;
|
|
66
|
+
sourceIp: z.ZodOptional<z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6, z.ZodUndefined]>>;
|
|
62
67
|
}, z.core.$strip>]>;
|
|
63
68
|
export type AssociationObject = z.output<typeof AssociationObjectSchema>;
|
|
64
69
|
export declare const ObjectPropertySchema: z.ZodObject<{
|
|
@@ -105,6 +110,19 @@ export declare const ObjectPropertySchema: z.ZodObject<{
|
|
|
105
110
|
}>>;
|
|
106
111
|
model: z.ZodLiteral<"Permission">;
|
|
107
112
|
id: z.ZodString;
|
|
113
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
114
|
+
model: z.ZodLiteral<"Session">;
|
|
115
|
+
createdAt: z.ZodPipe<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>, z.ZodTransform<string, Date>>;
|
|
116
|
+
id: z.ZodString;
|
|
117
|
+
status: z.ZodEnum<{
|
|
118
|
+
pending: "pending";
|
|
119
|
+
initiated: "initiated";
|
|
120
|
+
authenticated: "authenticated";
|
|
121
|
+
}>;
|
|
122
|
+
expiresAt: z.ZodPipe<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>, z.ZodTransform<string, Date>>;
|
|
123
|
+
user: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>>;
|
|
124
|
+
userAgent: z.ZodOptional<z.ZodString>;
|
|
125
|
+
sourceIp: z.ZodOptional<z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6, z.ZodUndefined]>>;
|
|
108
126
|
}, z.core.$strip>]>;
|
|
109
127
|
}, z.core.$strip>;
|
|
110
128
|
export declare const AssociationSchema: z.ZodObject<{
|
|
@@ -156,6 +174,19 @@ export declare const AssociationSchema: z.ZodObject<{
|
|
|
156
174
|
}>>;
|
|
157
175
|
model: z.ZodLiteral<"Permission">;
|
|
158
176
|
id: z.ZodString;
|
|
177
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
178
|
+
model: z.ZodLiteral<"Session">;
|
|
179
|
+
createdAt: z.ZodPipe<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>, z.ZodTransform<string, Date>>;
|
|
180
|
+
id: z.ZodString;
|
|
181
|
+
status: z.ZodEnum<{
|
|
182
|
+
pending: "pending";
|
|
183
|
+
initiated: "initiated";
|
|
184
|
+
authenticated: "authenticated";
|
|
185
|
+
}>;
|
|
186
|
+
expiresAt: z.ZodPipe<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>, z.ZodTransform<string, Date>>;
|
|
187
|
+
user: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>>;
|
|
188
|
+
userAgent: z.ZodOptional<z.ZodString>;
|
|
189
|
+
sourceIp: z.ZodOptional<z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6, z.ZodUndefined]>>;
|
|
159
190
|
}, z.core.$strip>]>;
|
|
160
191
|
}, z.core.$strip>;
|
|
161
192
|
declare const RootAssociationProperties: z.ZodObject<{
|
|
@@ -229,6 +260,19 @@ export declare const AssociationPayloadSchema: z.ZodObject<{
|
|
|
229
260
|
}>>;
|
|
230
261
|
model: z.ZodLiteral<"Permission">;
|
|
231
262
|
id: z.ZodString;
|
|
263
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
264
|
+
model: z.ZodLiteral<"Session">;
|
|
265
|
+
createdAt: z.ZodPipe<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>, z.ZodTransform<string, Date>>;
|
|
266
|
+
id: z.ZodString;
|
|
267
|
+
status: z.ZodEnum<{
|
|
268
|
+
pending: "pending";
|
|
269
|
+
initiated: "initiated";
|
|
270
|
+
authenticated: "authenticated";
|
|
271
|
+
}>;
|
|
272
|
+
expiresAt: z.ZodPipe<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>, z.ZodTransform<string, Date>>;
|
|
273
|
+
user: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>>;
|
|
274
|
+
userAgent: z.ZodOptional<z.ZodString>;
|
|
275
|
+
sourceIp: z.ZodOptional<z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6, z.ZodUndefined]>>;
|
|
232
276
|
}, z.core.$strip>]>;
|
|
233
277
|
}, z.core.$strip>;
|
|
234
278
|
type RootAssociationPayload = z.output<typeof AssociationPayloadSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/association/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/association/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAwB5B,eAAO,MAAM,qBAAqB;;;;;;;CAOxB,CAAC;AACX,MAAM,MAAM,wBAAwB,GAClC,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC;AAErE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAOlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAQzE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAE/B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAO5B,CAAC;AACH,QAAA,MAAM,yBAAyB;;;;;;iBAA2C,CAAC;AAC3E,KAAK,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC3E,MAAM,MAAM,qBAAqB,CAC/B,CAAC,SAAS,iBAAiB,GAAG,iBAAiB,IAC7C,yBAAyB,GAAG;IAC9B,MAAM,EAAE,CAAC,CAAC;CACX,CAAC;AACF,QAAA,MAAM,eAAe;;;;;;iBAA2C,CAAC;AACjE,KAAK,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AACxD,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB,IACrE,eAAe,GAAG;IAChB,MAAM,EAAE,CAAC,CAAC;CACX,CAAC;AAEJ,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAOnC,CAAC;AACH,KAAK,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAExE,MAAM,MAAM,kBAAkB,CAC5B,CAAC,SAAS,iBAAiB,GAAG,iBAAiB,IAC7C,sBAAsB,GAAG;IAC3B,MAAM,EAAE,CAAC,CAAC;CACX,CAAC;AAEF,eAAO,MAAM,8BAA8B;;;iBAGzC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAC1C,OAAO,8BAA8B,CACtC,CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAC7C,OAAO,8BAA8B,CACtC,CAAC"}
|
|
@@ -33,31 +33,30 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.UpsertAssociationPayloadSchema = exports.AssociationPayloadSchema = exports.AssociationSchema = exports.ObjectPropertySchema = exports.AssociationObjectSchema = exports.
|
|
36
|
+
exports.UpsertAssociationPayloadSchema = exports.AssociationPayloadSchema = exports.AssociationSchema = exports.ObjectPropertySchema = exports.AssociationObjectSchema = exports.AssociationObjectType = void 0;
|
|
37
37
|
const z = __importStar(require("zod/v4"));
|
|
38
38
|
const schema_js_1 = require("../app/schema.js");
|
|
39
|
+
const schema_js_2 = require("../authentication/sessions/schema.js");
|
|
39
40
|
const index_js_1 = require("../authorization/index.js");
|
|
40
41
|
const dates_js_1 = require("../common/schema/dates.js");
|
|
41
42
|
const metadata_js_1 = require("../common/schema/metadata.js");
|
|
42
|
-
const
|
|
43
|
-
const
|
|
43
|
+
const schema_js_3 = require("../customer/organization/schema.js");
|
|
44
|
+
const schema_js_4 = require("../customer/users/schema.js");
|
|
44
45
|
exports.AssociationObjectType = {
|
|
45
46
|
USER: 'User',
|
|
46
47
|
ORGANIZATION: 'Organization',
|
|
47
48
|
ROLE: 'Role',
|
|
48
49
|
APP: 'App',
|
|
49
50
|
PERMISSION: 'Permission',
|
|
51
|
+
SESSION: 'Session',
|
|
50
52
|
};
|
|
51
|
-
exports.AssociationIdReferenceSchema = z.object({
|
|
52
|
-
id: z.string(),
|
|
53
|
-
});
|
|
54
|
-
exports.AssociationAttributesReferenceSchema = exports.AssociationIdReferenceSchema.and(z.record(z.string(), z.unknown()));
|
|
55
53
|
exports.AssociationObjectSchema = z.union([
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
schema_js_4.UserAssociationReferenceSchema,
|
|
55
|
+
schema_js_3.OrganizationAssociationReferenceSchema,
|
|
58
56
|
schema_js_1.AppAssociationReferenceSchema,
|
|
59
57
|
index_js_1.RoleAssociationReferenceSchema,
|
|
60
58
|
index_js_1.PermissionAssociationReferenceSchema,
|
|
59
|
+
schema_js_2.SessionAssociationReferenceSchema,
|
|
61
60
|
]);
|
|
62
61
|
// export type AssociationObject =
|
|
63
62
|
// | UserAssociationReference
|
|
@@ -13,56 +13,7 @@ const schema_js_3 = require("./schema.js");
|
|
|
13
13
|
(0, vitest_1.expect)(schema_js_3.AssociationObjectType.ROLE).toBe('Role');
|
|
14
14
|
(0, vitest_1.expect)(schema_js_3.AssociationObjectType.APP).toBe('App');
|
|
15
15
|
(0, vitest_1.expect)(schema_js_3.AssociationObjectType.PERMISSION).toBe('Permission');
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
(0, vitest_1.describe)('AssociationIdReferenceSchema', () => {
|
|
19
|
-
(0, vitest_1.test)('should accept valid id reference', () => {
|
|
20
|
-
const reference = { id: 'any_string_id' };
|
|
21
|
-
const result = schema_js_3.AssociationIdReferenceSchema.safeParse(reference);
|
|
22
|
-
// Parse succeeds for valid data
|
|
23
|
-
(0, vitest_1.expect)(result.success).toBe(true);
|
|
24
|
-
if (result.success) {
|
|
25
|
-
(0, vitest_1.expect)(result.data).toEqual(reference);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
(0, vitest_1.test)('should reject missing id', () => {
|
|
29
|
-
const result = schema_js_3.AssociationIdReferenceSchema.safeParse({});
|
|
30
|
-
(0, vitest_1.expect)(result.success).toBe(false);
|
|
31
|
-
});
|
|
32
|
-
(0, vitest_1.test)('should reject non-string id', () => {
|
|
33
|
-
const reference = { id: 123 };
|
|
34
|
-
const result = schema_js_3.AssociationIdReferenceSchema.safeParse(reference);
|
|
35
|
-
(0, vitest_1.expect)(result.success).toBe(false);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
(0, vitest_1.describe)('AssociationAttributesReferenceSchema', () => {
|
|
39
|
-
(0, vitest_1.test)('should accept id with additional attributes', () => {
|
|
40
|
-
const reference = {
|
|
41
|
-
id: 'test_id',
|
|
42
|
-
name: 'Test Name',
|
|
43
|
-
status: 'active',
|
|
44
|
-
metadata: { key: 'value' },
|
|
45
|
-
};
|
|
46
|
-
const result = schema_js_3.AssociationAttributesReferenceSchema.safeParse(reference);
|
|
47
|
-
// Parse succeeds for valid data
|
|
48
|
-
(0, vitest_1.expect)(result.success).toBe(true);
|
|
49
|
-
if (result.success) {
|
|
50
|
-
(0, vitest_1.expect)(result.data).toEqual(reference);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
(0, vitest_1.test)('should accept minimal reference with just id', () => {
|
|
54
|
-
const reference = { id: 'minimal_id' };
|
|
55
|
-
const result = schema_js_3.AssociationAttributesReferenceSchema.safeParse(reference);
|
|
56
|
-
// Parse succeeds for valid data
|
|
57
|
-
(0, vitest_1.expect)(result.success).toBe(true);
|
|
58
|
-
if (result.success) {
|
|
59
|
-
(0, vitest_1.expect)(result.data).toEqual(reference);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
(0, vitest_1.test)('should reject missing id', () => {
|
|
63
|
-
const reference = { name: 'Test', status: 'active' };
|
|
64
|
-
const result = schema_js_3.AssociationAttributesReferenceSchema.safeParse(reference);
|
|
65
|
-
(0, vitest_1.expect)(result.success).toBe(false);
|
|
16
|
+
(0, vitest_1.expect)(schema_js_3.AssociationObjectType.SESSION).toBe('Session');
|
|
66
17
|
});
|
|
67
18
|
});
|
|
68
19
|
(0, vitest_1.describe)('AssociationObjectSchema', () => {
|
|
@@ -27,5 +27,5 @@ async function getSettings(instance) {
|
|
|
27
27
|
return schema_js_1.SettingsSchema.parse(await (0, operations_js_1.getItemWithAuthorization)(new URL(SettingsResources.buildPath(), instance.config.host), instance.authorizer));
|
|
28
28
|
}
|
|
29
29
|
async function upsertSettings(instance, item) {
|
|
30
|
-
return schema_js_1.SettingsSchema.parse(await (0, operations_js_1.
|
|
30
|
+
return schema_js_1.SettingsSchema.parse(await (0, operations_js_1.postItemWithAuthorization)(new URL(SettingsResources.buildPath(), instance.config.host), instance.authorizer, schema_js_1.UpsertSettingsPayloadSchema.parse(item)));
|
|
31
31
|
}
|
|
@@ -48,10 +48,10 @@ async function getStrategy(instance, id) {
|
|
|
48
48
|
return schema_js_1.StrategySchema.parse(await (0, operations_js_1.getItemWithAuthorization)(new URL(StrategyResources.buildItemPath(id), instance.config.host), instance.authorizer));
|
|
49
49
|
}
|
|
50
50
|
async function insertStrategy(instance, item) {
|
|
51
|
-
return schema_js_1.StrategySchema.parse(await (0, operations_js_1.
|
|
51
|
+
return schema_js_1.StrategySchema.parse(await (0, operations_js_1.postItemWithAuthorization)(new URL(StrategyResources.buildPath(), instance.config.host), instance.authorizer, schema_js_1.InsertStrategyPayloadSchema.parse(item)));
|
|
52
52
|
}
|
|
53
53
|
async function updateStrategy(instance, id, item) {
|
|
54
|
-
return schema_js_1.StrategySchema.parse(await (0, operations_js_1.
|
|
54
|
+
return schema_js_1.StrategySchema.parse(await (0, operations_js_1.patchItemWithAuthorization)(new URL(StrategyResources.buildItemPath(id), instance.config.host), instance.authorizer, schema_js_1.UpdateStrategyPayloadSchema.parse(item)));
|
|
55
55
|
}
|
|
56
56
|
async function deleteStrategy(instance, id) {
|
|
57
57
|
return schema_js_1.StrategySchema.parse(await (0, operations_js_1.deleteItemWithAuthorization)(new URL(StrategyResources.buildItemPath(id), instance.config.host), instance.authorizer));
|
|
@@ -47,10 +47,10 @@ async function getPermission(instance, id) {
|
|
|
47
47
|
return schema_js_1.PermissionSchema.parse(await (0, operations_js_1.getItemWithAuthorization)(new URL(PermissionResources.buildPath(id), instance.config.host), instance.authorizer));
|
|
48
48
|
}
|
|
49
49
|
async function insertPermission(instance, item) {
|
|
50
|
-
return schema_js_1.PermissionSchema.parse(await (0, operations_js_1.
|
|
50
|
+
return schema_js_1.PermissionSchema.parse(await (0, operations_js_1.postItemWithAuthorization)(new URL(PermissionResources.buildPath(), instance.config.host), instance.authorizer, schema_js_1.InsertPermissionPayloadSchema.parse(item)));
|
|
51
51
|
}
|
|
52
52
|
async function updatePermission(instance, id, item) {
|
|
53
|
-
return schema_js_1.PermissionSchema.parse(await (0, operations_js_1.
|
|
53
|
+
return schema_js_1.PermissionSchema.parse(await (0, operations_js_1.patchItemWithAuthorization)(new URL(PermissionResources.buildPath(id), instance.config.host), instance.authorizer, schema_js_1.UpdatePermissionPayloadSchema.parse(item)));
|
|
54
54
|
}
|
|
55
55
|
async function deletePermission(instance, id) {
|
|
56
56
|
return schema_js_1.PermissionSchema.parse(await (0, operations_js_1.deleteItemWithAuthorization)(new URL(PermissionResources.buildPath(id), instance.config.host), instance.authorizer));
|
|
@@ -47,10 +47,10 @@ async function getRole(instance, id) {
|
|
|
47
47
|
return schema_js_1.RoleSchema.parse(await (0, operations_js_1.getItemWithAuthorization)(new URL(RoleResources.buildPath(id), instance.config.host), instance.authorizer));
|
|
48
48
|
}
|
|
49
49
|
async function insertRole(instance, item) {
|
|
50
|
-
return schema_js_1.RoleSchema.parse(await (0, operations_js_1.
|
|
50
|
+
return schema_js_1.RoleSchema.parse(await (0, operations_js_1.postItemWithAuthorization)(new URL(RoleResources.buildPath(), instance.config.host), instance.authorizer, schema_js_1.InsertRolePayloadSchema.parse(item)));
|
|
51
51
|
}
|
|
52
52
|
async function updateRole(instance, id, item) {
|
|
53
|
-
return schema_js_1.RoleSchema.parse(await (0, operations_js_1.
|
|
53
|
+
return schema_js_1.RoleSchema.parse(await (0, operations_js_1.patchItemWithAuthorization)(new URL(RoleResources.buildPath(id), instance.config.host), instance.authorizer, schema_js_1.UpdateRolePayloadSchema.parse(item)));
|
|
54
54
|
}
|
|
55
55
|
async function deleteRole(instance, id) {
|
|
56
56
|
return schema_js_1.RoleSchema.parse(await (0, operations_js_1.deleteItemWithAuthorization)(new URL(RoleResources.buildPath(id), instance.config.host), instance.authorizer));
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Authorization } from './authorization.js';
|
|
2
2
|
export declare function listItemsWithAuthorization<Result>(url: URL, authorization: Authorization): Promise<Result>;
|
|
3
3
|
export declare function getItemWithAuthorization<Result>(url: URL, authorization: Authorization): Promise<Result>;
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
4
|
+
export declare function patchItemWithAuthorization<Result, Mutation>(url: URL, authorization: Authorization, item: Mutation): Promise<Result>;
|
|
5
|
+
export declare function putItemWithAuthorization<Result, Mutation>(url: URL, authorization: Authorization, item: Mutation): Promise<Result>;
|
|
6
|
+
export declare function postItemWithAuthorization<Result, Mutation>(url: URL, authorization: Authorization, item?: Mutation): Promise<Result>;
|
|
6
7
|
export declare function deleteItemWithAuthorization<Result>(url: URL, authorization: Authorization): Promise<Result>;
|
|
7
8
|
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../../../src/common/resources/operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AASxD,wBAAsB,0BAA0B,CAAC,MAAM,EACrD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAED,wBAAsB,wBAAwB,CAAC,MAAM,EACnD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAED,wBAAsB,
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../../../src/common/resources/operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AASxD,wBAAsB,0BAA0B,CAAC,MAAM,EACrD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAED,wBAAsB,wBAAwB,CAAC,MAAM,EACnD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAED,wBAAsB,0BAA0B,CAAC,MAAM,EAAE,QAAQ,EAC/D,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,wBAAsB,wBAAwB,CAAC,MAAM,EAAE,QAAQ,EAC7D,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,MAAM,CAAC,CAEjB;AA8BD,wBAAsB,yBAAyB,CAAC,MAAM,EAAE,QAAQ,EAC9D,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,IAAI,CAAC,EAAE,QAAQ,GACd,OAAO,CAAC,MAAM,CAAC,CAqBjB;AAED,wBAAsB,2BAA2B,CAAC,MAAM,EACtD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,MAAM,CAAC,CAoBjB"}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.listItemsWithAuthorization = listItemsWithAuthorization;
|
|
4
4
|
exports.getItemWithAuthorization = getItemWithAuthorization;
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
5
|
+
exports.patchItemWithAuthorization = patchItemWithAuthorization;
|
|
6
|
+
exports.putItemWithAuthorization = putItemWithAuthorization;
|
|
7
|
+
exports.postItemWithAuthorization = postItemWithAuthorization;
|
|
7
8
|
exports.deleteItemWithAuthorization = deleteItemWithAuthorization;
|
|
8
9
|
const utils_js_1 = require("./utils.js");
|
|
9
10
|
async function listItemsWithAuthorization(url, authorization) {
|
|
@@ -24,7 +25,7 @@ async function listItemsWithAuthorization(url, authorization) {
|
|
|
24
25
|
}
|
|
25
26
|
async function getItemWithAuthorization(url, authorization) {
|
|
26
27
|
try {
|
|
27
|
-
console.debug('
|
|
28
|
+
console.debug('GET item', { url });
|
|
28
29
|
const response = await fetch(url, authorization({
|
|
29
30
|
method: 'GET',
|
|
30
31
|
headers: (0, utils_js_1.defaultRequestHeaders)(),
|
|
@@ -38,11 +39,17 @@ async function getItemWithAuthorization(url, authorization) {
|
|
|
38
39
|
throw (0, utils_js_1.toHttpError)(error);
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
|
-
async function
|
|
42
|
+
async function patchItemWithAuthorization(url, authorization, item) {
|
|
43
|
+
return mutateItemWithAuthorization('PATCH', url, authorization, item);
|
|
44
|
+
}
|
|
45
|
+
async function putItemWithAuthorization(url, authorization, item) {
|
|
46
|
+
return mutateItemWithAuthorization('PUT', url, authorization, item);
|
|
47
|
+
}
|
|
48
|
+
async function mutateItemWithAuthorization(method, url, authorization, item) {
|
|
42
49
|
try {
|
|
43
|
-
console.debug(
|
|
50
|
+
console.debug(`${method} item`, { url, item });
|
|
44
51
|
const response = await fetch(url, authorization({
|
|
45
|
-
method
|
|
52
|
+
method,
|
|
46
53
|
headers: (0, utils_js_1.defaultMutationRequestHeaders)(),
|
|
47
54
|
body: JSON.stringify(item),
|
|
48
55
|
}));
|
|
@@ -55,9 +62,9 @@ async function updateItemWithAuthorization(url, authorization, item) {
|
|
|
55
62
|
throw (0, utils_js_1.toHttpError)(error);
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
|
-
async function
|
|
65
|
+
async function postItemWithAuthorization(url, authorization, item) {
|
|
59
66
|
try {
|
|
60
|
-
console.debug('
|
|
67
|
+
console.debug('POST item', { url, item });
|
|
61
68
|
const response = await fetch(url, authorization({
|
|
62
69
|
method: 'POST',
|
|
63
70
|
headers: (0, utils_js_1.defaultMutationRequestHeaders)(),
|
|
@@ -113,7 +113,7 @@ global.fetch = mockFetch;
|
|
|
113
113
|
json: () => Promise.resolve({}),
|
|
114
114
|
});
|
|
115
115
|
await (0, operations_js_1.getItemWithAuthorization)(testUrl, mockAuthorization);
|
|
116
|
-
(0, vitest_1.expect)(console.debug).toHaveBeenCalledWith('
|
|
116
|
+
(0, vitest_1.expect)(console.debug).toHaveBeenCalledWith('GET item', { url: testUrl });
|
|
117
117
|
});
|
|
118
118
|
});
|
|
119
119
|
(0, vitest_1.describe)('updateItemWithAuthorization', () => {
|
|
@@ -124,7 +124,7 @@ global.fetch = mockFetch;
|
|
|
124
124
|
ok: true,
|
|
125
125
|
json: () => Promise.resolve(responseData),
|
|
126
126
|
});
|
|
127
|
-
const result = await (0, operations_js_1.
|
|
127
|
+
const result = await (0, operations_js_1.putItemWithAuthorization)(testUrl, mockAuthorization, updateData);
|
|
128
128
|
(0, vitest_1.expect)(result).toEqual(responseData);
|
|
129
129
|
(0, vitest_1.expect)(mockFetch).toHaveBeenCalledWith(testUrl, vitest_1.expect.objectContaining({
|
|
130
130
|
method: 'PUT',
|
|
@@ -138,7 +138,7 @@ global.fetch = mockFetch;
|
|
|
138
138
|
ok: true,
|
|
139
139
|
json: () => Promise.resolve({}),
|
|
140
140
|
});
|
|
141
|
-
await (0, operations_js_1.
|
|
141
|
+
await (0, operations_js_1.putItemWithAuthorization)(testUrl, mockAuthorization, updateData);
|
|
142
142
|
const authCall = mockAuthorization.mock.calls[0][0];
|
|
143
143
|
const headers = authCall.headers;
|
|
144
144
|
(0, vitest_1.expect)(headers.get('accept')).toBe('application/json');
|
|
@@ -154,7 +154,7 @@ global.fetch = mockFetch;
|
|
|
154
154
|
fields: { name: ['required'] },
|
|
155
155
|
}),
|
|
156
156
|
});
|
|
157
|
-
await (0, vitest_1.expect)((0, operations_js_1.
|
|
157
|
+
await (0, vitest_1.expect)((0, operations_js_1.putItemWithAuthorization)(testUrl, mockAuthorization, {})).rejects.toThrow(validation_js_1.ValidationError);
|
|
158
158
|
});
|
|
159
159
|
(0, vitest_1.test)('should log debug information with item data', async () => {
|
|
160
160
|
const updateData = { name: 'Test Item' };
|
|
@@ -162,8 +162,8 @@ global.fetch = mockFetch;
|
|
|
162
162
|
ok: true,
|
|
163
163
|
json: () => Promise.resolve({}),
|
|
164
164
|
});
|
|
165
|
-
await (0, operations_js_1.
|
|
166
|
-
(0, vitest_1.expect)(console.debug).toHaveBeenCalledWith('
|
|
165
|
+
await (0, operations_js_1.putItemWithAuthorization)(testUrl, mockAuthorization, updateData);
|
|
166
|
+
(0, vitest_1.expect)(console.debug).toHaveBeenCalledWith('PUT item', {
|
|
167
167
|
url: testUrl,
|
|
168
168
|
item: updateData,
|
|
169
169
|
});
|
|
@@ -177,7 +177,7 @@ global.fetch = mockFetch;
|
|
|
177
177
|
ok: true,
|
|
178
178
|
json: () => Promise.resolve(responseData),
|
|
179
179
|
});
|
|
180
|
-
const result = await (0, operations_js_1.
|
|
180
|
+
const result = await (0, operations_js_1.postItemWithAuthorization)(testUrl, mockAuthorization, insertData);
|
|
181
181
|
(0, vitest_1.expect)(result).toEqual(responseData);
|
|
182
182
|
(0, vitest_1.expect)(mockFetch).toHaveBeenCalledWith(testUrl, vitest_1.expect.objectContaining({
|
|
183
183
|
method: 'POST',
|
|
@@ -191,7 +191,7 @@ global.fetch = mockFetch;
|
|
|
191
191
|
ok: true,
|
|
192
192
|
json: () => Promise.resolve(responseData),
|
|
193
193
|
});
|
|
194
|
-
const result = await (0, operations_js_1.
|
|
194
|
+
const result = await (0, operations_js_1.postItemWithAuthorization)(testUrl, mockAuthorization);
|
|
195
195
|
(0, vitest_1.expect)(result).toEqual(responseData);
|
|
196
196
|
(0, vitest_1.expect)(mockFetch).toHaveBeenCalledWith(testUrl, vitest_1.expect.objectContaining({
|
|
197
197
|
method: 'POST',
|
|
@@ -205,7 +205,7 @@ global.fetch = mockFetch;
|
|
|
205
205
|
ok: true,
|
|
206
206
|
json: () => Promise.resolve(responseData),
|
|
207
207
|
});
|
|
208
|
-
const result = await (0, operations_js_1.
|
|
208
|
+
const result = await (0, operations_js_1.postItemWithAuthorization)(testUrl, mockAuthorization, null);
|
|
209
209
|
(0, vitest_1.expect)(result).toEqual(responseData);
|
|
210
210
|
(0, vitest_1.expect)(mockFetch).toHaveBeenCalledWith(testUrl, vitest_1.expect.objectContaining({
|
|
211
211
|
method: 'POST',
|
|
@@ -221,7 +221,7 @@ global.fetch = mockFetch;
|
|
|
221
221
|
error_description: 'Internal server error',
|
|
222
222
|
}),
|
|
223
223
|
});
|
|
224
|
-
await (0, vitest_1.expect)((0, operations_js_1.
|
|
224
|
+
await (0, vitest_1.expect)((0, operations_js_1.postItemWithAuthorization)(testUrl, mockAuthorization, {})).rejects.toThrow(http_js_1.HttpError);
|
|
225
225
|
});
|
|
226
226
|
(0, vitest_1.test)('should log debug information', async () => {
|
|
227
227
|
const insertData = { name: 'Test' };
|
|
@@ -229,8 +229,8 @@ global.fetch = mockFetch;
|
|
|
229
229
|
ok: true,
|
|
230
230
|
json: () => Promise.resolve({}),
|
|
231
231
|
});
|
|
232
|
-
await (0, operations_js_1.
|
|
233
|
-
(0, vitest_1.expect)(console.debug).toHaveBeenCalledWith('
|
|
232
|
+
await (0, operations_js_1.postItemWithAuthorization)(testUrl, mockAuthorization, insertData);
|
|
233
|
+
(0, vitest_1.expect)(console.debug).toHaveBeenCalledWith('POST item', {
|
|
234
234
|
url: testUrl,
|
|
235
235
|
item: insertData,
|
|
236
236
|
});
|
|
@@ -296,8 +296,8 @@ global.fetch = mockFetch;
|
|
|
296
296
|
const operations = [
|
|
297
297
|
() => (0, operations_js_1.listItemsWithAuthorization)(testUrl, mockAuthorization),
|
|
298
298
|
() => (0, operations_js_1.getItemWithAuthorization)(testUrl, mockAuthorization),
|
|
299
|
-
() => (0, operations_js_1.
|
|
300
|
-
() => (0, operations_js_1.
|
|
299
|
+
() => (0, operations_js_1.putItemWithAuthorization)(testUrl, mockAuthorization, {}),
|
|
300
|
+
() => (0, operations_js_1.postItemWithAuthorization)(testUrl, mockAuthorization, {}),
|
|
301
301
|
() => (0, operations_js_1.deleteItemWithAuthorization)(testUrl, mockAuthorization),
|
|
302
302
|
];
|
|
303
303
|
// Mock successful responses for all operations
|
|
@@ -350,7 +350,7 @@ global.fetch = mockFetch;
|
|
|
350
350
|
status: 400,
|
|
351
351
|
json: () => Promise.resolve({}),
|
|
352
352
|
});
|
|
353
|
-
await (0, vitest_1.expect)((0, operations_js_1.
|
|
353
|
+
await (0, vitest_1.expect)((0, operations_js_1.putItemWithAuthorization)(testUrl, mockAuthorization, {})).rejects.toThrow(http_js_1.HttpError);
|
|
354
354
|
});
|
|
355
355
|
});
|
|
356
356
|
});
|
|
@@ -47,10 +47,10 @@ async function getUser(instance, id) {
|
|
|
47
47
|
return schema_js_1.UserSchema.parse(await (0, operations_js_1.getItemWithAuthorization)(new URL(UserResources.buildPath(id), instance.config.host), instance.authorizer));
|
|
48
48
|
}
|
|
49
49
|
async function insertUser(instance, item) {
|
|
50
|
-
return schema_js_1.UserSchema.parse(await (0, operations_js_1.
|
|
50
|
+
return schema_js_1.UserSchema.parse(await (0, operations_js_1.postItemWithAuthorization)(new URL(UserResources.buildPath(), instance.config.host), instance.authorizer, schema_js_1.InsertUserPayloadSchema.parse(item)));
|
|
51
51
|
}
|
|
52
52
|
async function updateUser(instance, id, item) {
|
|
53
|
-
return schema_js_1.UserSchema.parse(await (0, operations_js_1.
|
|
53
|
+
return schema_js_1.UserSchema.parse(await (0, operations_js_1.patchItemWithAuthorization)(new URL(UserResources.buildPath(id), instance.config.host), instance.authorizer, schema_js_1.UpdateUserPayloadSchema.parse(item)));
|
|
54
54
|
}
|
|
55
55
|
async function deleteUser(instance, id) {
|
|
56
56
|
return schema_js_1.UserSchema.parse(await (0, operations_js_1.deleteItemWithAuthorization)(new URL(UserResources.buildPath(id), instance.config.host), instance.authorizer));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getItemWithAuthorization,
|
|
1
|
+
import { getItemWithAuthorization, putItemWithAuthorization, } from '../../common/resources/operations.js';
|
|
2
2
|
import { PATH } from '../resources.js';
|
|
3
3
|
import { AuthorizationSchema, UpsertAuthorizationPayloadSchema, } from './schema.js';
|
|
4
4
|
const RESOURCE = 'authorization';
|
|
@@ -21,5 +21,5 @@ export async function getAuthorization(instance, appId) {
|
|
|
21
21
|
return AuthorizationSchema.parse(await getItemWithAuthorization(new URL(AuthorizationResources.buildPath(appId), instance.config.host), instance.authorizer));
|
|
22
22
|
}
|
|
23
23
|
export async function upsertAuthorization(instance, appId, item) {
|
|
24
|
-
return AuthorizationSchema.parse(await
|
|
24
|
+
return AuthorizationSchema.parse(await putItemWithAuthorization(new URL(AuthorizationResources.buildPath(appId), instance.config.host), instance.authorizer, UpsertAuthorizationPayloadSchema.parse(item)));
|
|
25
25
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getItemWithAuthorization,
|
|
1
|
+
import { getItemWithAuthorization, postItemWithAuthorization, } from '../../common/resources/operations.js';
|
|
2
2
|
import { PATH } from '../resources.js';
|
|
3
3
|
import { InsertOAuthPayloadSchema, OAuthSchema, } from './schema.js';
|
|
4
4
|
const RESOURCE = 'oauth';
|
|
@@ -24,5 +24,5 @@ export async function getOAuth(instance, appId) {
|
|
|
24
24
|
return OAuthSchema.parse(await getItemWithAuthorization(new URL(OAuthResources.buildPath(appId), instance.config.host), instance.authorizer));
|
|
25
25
|
}
|
|
26
26
|
export async function rotateOAuthSecret(instance, appId, item) {
|
|
27
|
-
return OAuthSchema.parse(await
|
|
27
|
+
return OAuthSchema.parse(await postItemWithAuthorization(new URL(OAuthResources.buildPath(appId), instance.config.host), instance.authorizer, InsertOAuthPayloadSchema.parse(item)));
|
|
28
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { deleteItemWithAuthorization, getItemWithAuthorization,
|
|
1
|
+
import { deleteItemWithAuthorization, getItemWithAuthorization, patchItemWithAuthorization, postItemWithAuthorization, } from '../../common/resources/operations.js';
|
|
2
2
|
import { PATH } from '../resources.js';
|
|
3
3
|
import { InsertOIDCPayloadSchema, OIDCSchema, UpdateOIDCPayloadSchema, } from './schema.js';
|
|
4
4
|
const RESOURCE = 'oidc';
|
|
@@ -30,10 +30,10 @@ export async function getOIDC(instance, appId) {
|
|
|
30
30
|
return OIDCSchema.parse(await getItemWithAuthorization(new URL(OIDCResources.buildPath(appId), instance.config.host), instance.authorizer));
|
|
31
31
|
}
|
|
32
32
|
export async function insertOIDC(instance, appId, item) {
|
|
33
|
-
return OIDCSchema.parse(await
|
|
33
|
+
return OIDCSchema.parse(await postItemWithAuthorization(new URL(OIDCResources.buildPath(appId), instance.config.host), instance.authorizer, item ? InsertOIDCPayloadSchema.parse(item) : undefined));
|
|
34
34
|
}
|
|
35
35
|
export async function updateOIDC(instance, appId, item) {
|
|
36
|
-
return OIDCSchema.parse(await
|
|
36
|
+
return OIDCSchema.parse(await patchItemWithAuthorization(new URL(OIDCResources.buildPath(appId), instance.config.host), instance.authorizer, UpdateOIDCPayloadSchema.parse(item)));
|
|
37
37
|
}
|
|
38
38
|
export async function deleteOIDC(instance, appId) {
|
|
39
39
|
return OIDCSchema.parse(await deleteItemWithAuthorization(new URL(OIDCResources.buildPath(appId), instance.config.host), instance.authorizer));
|