@labdigital/commercetools-mock 2.66.0 → 3.0.0-beta.0
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/README.md +31 -8
- package/dist/abstract-BKFcva6S.mjs +1044 -0
- package/dist/abstract-BKFcva6S.mjs.map +1 -0
- package/dist/config-BcNSzPZz.d.mts +1718 -0
- package/dist/index.d.mts +50 -1633
- package/dist/index.mjs +3769 -2653
- package/dist/index.mjs.map +1 -1
- package/dist/storage/sqlite.d.mts +59 -0
- package/dist/storage/sqlite.mjs +234 -0
- package/dist/storage/sqlite.mjs.map +1 -0
- package/package.json +26 -29
- package/src/ctMock.ts +125 -136
- package/src/helpers.ts +14 -6
- package/src/index.ts +5 -0
- package/src/lib/masking.ts +4 -5
- package/src/lib/product-review-statistics.test.ts +257 -294
- package/src/lib/review-statistics.ts +17 -4
- package/src/oauth/helpers.ts +7 -4
- package/src/oauth/server.test.ts +102 -62
- package/src/oauth/server.ts +215 -213
- package/src/oauth/store.ts +20 -6
- package/src/orderSearch.ts +3 -3
- package/src/product-projection-search.ts +38 -20
- package/src/product-search-availability.test.ts +31 -52
- package/src/product-search.ts +19 -10
- package/src/projectAPI.ts +6 -22
- package/src/repositories/abstract.ts +182 -48
- package/src/repositories/as-associate.test.ts +19 -19
- package/src/repositories/associate-role.ts +12 -23
- package/src/repositories/attribute-group.test.ts +23 -23
- package/src/repositories/attribute-group.ts +6 -4
- package/src/repositories/business-unit.test.ts +63 -57
- package/src/repositories/business-unit.ts +107 -55
- package/src/repositories/cart/actions.ts +96 -65
- package/src/repositories/cart/helpers.ts +15 -11
- package/src/repositories/cart/index.test.ts +136 -30
- package/src/repositories/cart/index.ts +76 -59
- package/src/repositories/cart-discount/actions.ts +12 -44
- package/src/repositories/cart-discount/index.ts +20 -8
- package/src/repositories/category/actions.ts +27 -27
- package/src/repositories/category/index.test.ts +13 -9
- package/src/repositories/category/index.ts +40 -23
- package/src/repositories/channel.test.ts +53 -51
- package/src/repositories/channel.ts +12 -22
- package/src/repositories/custom-object.ts +34 -25
- package/src/repositories/customer/actions.ts +47 -25
- package/src/repositories/customer/index.test.ts +11 -11
- package/src/repositories/customer/index.ts +65 -35
- package/src/repositories/customer-group.test.ts +44 -42
- package/src/repositories/customer-group.ts +12 -22
- package/src/repositories/discount-code/actions.ts +3 -19
- package/src/repositories/discount-code/index.ts +9 -4
- package/src/repositories/discount-group/index.ts +8 -3
- package/src/repositories/extension.test.ts +27 -27
- package/src/repositories/extension.ts +10 -5
- package/src/repositories/helpers.ts +126 -47
- package/src/repositories/inventory-entry/actions.ts +3 -24
- package/src/repositories/inventory-entry/index.ts +19 -11
- package/src/repositories/my-customer.ts +13 -12
- package/src/repositories/my-order.ts +5 -2
- package/src/repositories/order/actions.ts +84 -56
- package/src/repositories/order/index.test.ts +36 -31
- package/src/repositories/order/index.ts +83 -49
- package/src/repositories/order-edit.ts +8 -3
- package/src/repositories/payment/actions.ts +64 -44
- package/src/repositories/payment/helpers.ts +3 -3
- package/src/repositories/payment/index.ts +28 -12
- package/src/repositories/product/actions.ts +133 -98
- package/src/repositories/product/helpers.ts +29 -16
- package/src/repositories/product/index.ts +42 -25
- package/src/repositories/product-discount.ts +6 -4
- package/src/repositories/product-projection.ts +41 -21
- package/src/repositories/product-selection.ts +8 -15
- package/src/repositories/product-tailoring.ts +22 -3
- package/src/repositories/product-type.ts +45 -4
- package/src/repositories/project.ts +57 -13
- package/src/repositories/quote/actions.ts +5 -28
- package/src/repositories/quote/index.ts +29 -6
- package/src/repositories/quote-request/actions.ts +5 -28
- package/src/repositories/quote-request/index.test.ts +3 -3
- package/src/repositories/quote-request/index.ts +31 -11
- package/src/repositories/quote-staged/actions.ts +5 -28
- package/src/repositories/quote-staged/index.ts +22 -8
- package/src/repositories/recurrence-policy/index.ts +6 -4
- package/src/repositories/recurring-order/actions.ts +7 -32
- package/src/repositories/recurring-order/index.ts +8 -6
- package/src/repositories/review.test.ts +147 -142
- package/src/repositories/review.ts +31 -37
- package/src/repositories/shipping-method/actions.ts +11 -28
- package/src/repositories/shipping-method/index.ts +26 -15
- package/src/repositories/shopping-list/actions.ts +21 -31
- package/src/repositories/shopping-list/index.ts +44 -22
- package/src/repositories/standalone-price.ts +6 -4
- package/src/repositories/state.ts +15 -9
- package/src/repositories/store.ts +21 -32
- package/src/repositories/subscription.test.ts +22 -22
- package/src/repositories/subscription.ts +8 -3
- package/src/repositories/tax-category/index.ts +8 -3
- package/src/repositories/type/actions.ts +21 -3
- package/src/repositories/type/index.ts +5 -3
- package/src/repositories/zone.test.ts +112 -77
- package/src/repositories/zone.ts +5 -3
- package/src/schemas/generated/associate-role.ts +13 -0
- package/src/schemas/generated/attribute-group.ts +12 -0
- package/src/schemas/generated/business-unit.ts +38 -0
- package/src/schemas/generated/cart-discount.ts +33 -0
- package/src/schemas/generated/cart.ts +61 -0
- package/src/schemas/generated/category.ts +25 -0
- package/src/schemas/generated/channel.ts +21 -0
- package/src/schemas/generated/common.ts +1372 -0
- package/src/schemas/generated/custom-object.ts +11 -0
- package/src/schemas/generated/customer-group.ts +11 -0
- package/src/schemas/generated/customer.ts +47 -0
- package/src/schemas/generated/discount-code.ts +25 -0
- package/src/schemas/generated/discount-group.ts +13 -0
- package/src/schemas/generated/extension.ts +15 -0
- package/src/schemas/generated/index.ts +42 -0
- package/src/schemas/generated/inventory-entry.ts +20 -0
- package/src/schemas/generated/my-quote-request.ts +10 -0
- package/src/schemas/generated/order-edit.ts +18 -0
- package/src/schemas/generated/order-from-cart.ts +25 -0
- package/src/schemas/generated/payment.ts +30 -0
- package/src/schemas/generated/product-discount.ts +20 -0
- package/src/schemas/generated/product-selection.ts +18 -0
- package/src/schemas/generated/product-tailoring.ts +26 -0
- package/src/schemas/generated/product-type.ts +12 -0
- package/src/schemas/generated/product.ts +37 -0
- package/src/schemas/generated/quote-request.ts +19 -0
- package/src/schemas/generated/quote.ts +18 -0
- package/src/schemas/generated/recurrence-policy.ts +15 -0
- package/src/schemas/generated/recurring-order.ts +19 -0
- package/src/schemas/generated/review.ts +24 -0
- package/src/schemas/generated/shipping-method.ts +24 -0
- package/src/schemas/generated/shopping-list.ts +28 -0
- package/src/schemas/generated/staged-quote.ts +18 -0
- package/src/schemas/generated/standalone-price.ts +32 -0
- package/src/schemas/generated/state.ts +20 -0
- package/src/schemas/generated/store.ts +23 -0
- package/src/schemas/generated/subscription.ts +20 -0
- package/src/schemas/generated/tax-category.ts +12 -0
- package/src/schemas/generated/type.ts +17 -0
- package/src/schemas/generated/zone.ts +12 -0
- package/src/schemas/update-request.ts +3 -5
- package/src/server.ts +32 -4
- package/src/services/abstract.ts +207 -101
- package/src/services/as-associate-cart.test.ts +28 -36
- package/src/services/as-associate-cart.ts +15 -12
- package/src/services/as-associate-order.test.ts +33 -40
- package/src/services/as-associate-order.ts +15 -12
- package/src/services/as-associate-quote-request.ts +15 -12
- package/src/services/as-associate-shopping-list.test.ts +25 -35
- package/src/services/as-associate-shopping-list.ts +15 -12
- package/src/services/as-associate.test.ts +21 -15
- package/src/services/as-associate.ts +23 -22
- package/src/services/associate-roles.test.ts +16 -22
- package/src/services/associate-roles.ts +2 -2
- package/src/services/attribute-group.test.ts +40 -44
- package/src/services/attribute-group.ts +2 -2
- package/src/services/business-units.test.ts +227 -163
- package/src/services/business-units.ts +2 -2
- package/src/services/cart-discount.test.ts +253 -187
- package/src/services/cart-discount.ts +2 -2
- package/src/services/cart.test.ts +833 -832
- package/src/services/cart.ts +31 -12
- package/src/services/category.test.ts +208 -130
- package/src/services/category.ts +2 -2
- package/src/services/channel.test.ts +39 -44
- package/src/services/channel.ts +2 -2
- package/src/services/custom-object.test.ts +103 -79
- package/src/services/custom-object.ts +106 -38
- package/src/services/customer-group.test.ts +39 -44
- package/src/services/customer-group.ts +2 -2
- package/src/services/customer.test.ts +357 -292
- package/src/services/customer.ts +70 -23
- package/src/services/discount-code.test.ts +57 -68
- package/src/services/discount-code.ts +2 -2
- package/src/services/discount-group.test.ts +111 -134
- package/src/services/discount-group.ts +2 -2
- package/src/services/draft-validation.test.ts +255 -0
- package/src/services/extension.test.ts +39 -44
- package/src/services/extension.ts +2 -2
- package/src/services/inventory-entry.test.ts +106 -87
- package/src/services/inventory-entry.ts +2 -2
- package/src/services/my-business-unit.test.ts +82 -112
- package/src/services/my-business-unit.ts +25 -19
- package/src/services/my-cart.test.ts +46 -41
- package/src/services/my-cart.ts +32 -28
- package/src/services/my-customer.test.ts +153 -88
- package/src/services/my-customer.ts +130 -61
- package/src/services/my-order.ts +15 -12
- package/src/services/my-payment.test.ts +30 -24
- package/src/services/my-payment.ts +2 -2
- package/src/services/my-shopping-list.ts +2 -2
- package/src/services/order.test.ts +332 -276
- package/src/services/order.ts +45 -27
- package/src/services/payment.test.ts +31 -29
- package/src/services/payment.ts +2 -2
- package/src/services/product-discount.test.ts +39 -46
- package/src/services/product-discount.ts +2 -2
- package/src/services/product-projection.test.ts +176 -166
- package/src/services/product-projection.ts +31 -15
- package/src/services/product-selection.test.ts +17 -9
- package/src/services/product-selection.ts +2 -2
- package/src/services/product-type.test.ts +80 -21
- package/src/services/product-type.ts +2 -2
- package/src/services/product.test.ts +569 -534
- package/src/services/product.ts +14 -7
- package/src/services/project.test.ts +22 -12
- package/src/services/project.ts +28 -13
- package/src/services/quote-request.test.ts +36 -39
- package/src/services/quote-request.ts +2 -2
- package/src/services/quote-staged.ts +2 -2
- package/src/services/quote.ts +2 -2
- package/src/services/recurrence-policy.test.ts +114 -139
- package/src/services/recurrence-policy.ts +2 -2
- package/src/services/recurring-order.test.ts +149 -194
- package/src/services/recurring-order.ts +2 -2
- package/src/services/reviews.test.ts +127 -106
- package/src/services/reviews.ts +2 -2
- package/src/services/shipping-method.test.ts +96 -125
- package/src/services/shipping-method.ts +24 -12
- package/src/services/shopping-list.test.ts +183 -141
- package/src/services/shopping-list.ts +2 -2
- package/src/services/standalone-price.test.ts +60 -46
- package/src/services/standalone-price.ts +2 -2
- package/src/services/state.test.ts +20 -25
- package/src/services/state.ts +2 -2
- package/src/services/store.test.ts +26 -45
- package/src/services/store.ts +2 -2
- package/src/services/subscription.test.ts +39 -44
- package/src/services/subscription.ts +2 -2
- package/src/services/tax-category.test.ts +33 -36
- package/src/services/tax-category.ts +2 -2
- package/src/services/type.test.ts +45 -44
- package/src/services/type.ts +2 -2
- package/src/services/zone.test.ts +40 -44
- package/src/services/zone.ts +2 -2
- package/src/shipping.ts +41 -11
- package/src/storage/abstract.ts +248 -17
- package/src/storage/in-memory.ts +147 -290
- package/src/storage/sqlite.ts +429 -0
- package/src/storage/storage-map.ts +75 -0
- package/src/storage/storage.test-helpers.ts +97 -0
- package/src/storage/storage.test.ts +802 -0
- package/src/testing/associate-role.ts +28 -0
- package/src/testing/attribute-group.ts +27 -0
- package/src/testing/business-unit.ts +9 -8
- package/src/testing/cart-discount.ts +34 -0
- package/src/testing/cart.ts +20 -0
- package/src/testing/category.ts +25 -0
- package/src/testing/channel.ts +23 -0
- package/src/testing/custom-object.ts +27 -0
- package/src/testing/customer-group.ts +26 -0
- package/src/testing/customer.ts +36 -33
- package/src/testing/discount-code.ts +29 -0
- package/src/testing/discount-group.ts +27 -0
- package/src/testing/extension.ts +32 -0
- package/src/testing/index.ts +33 -0
- package/src/testing/inventory-entry.ts +26 -0
- package/src/testing/order.ts +27 -0
- package/src/testing/payment.ts +23 -0
- package/src/testing/product-discount.ts +33 -0
- package/src/testing/product-selection.ts +28 -0
- package/src/testing/product-type.ts +27 -0
- package/src/testing/product.ts +38 -0
- package/src/testing/quote-request.ts +29 -0
- package/src/testing/recurrence-policy.ts +33 -0
- package/src/testing/recurring-order.ts +32 -0
- package/src/testing/review.ts +24 -0
- package/src/testing/shipping-method.ts +31 -0
- package/src/testing/shopping-list.ts +25 -0
- package/src/testing/standalone-price.ts +31 -0
- package/src/testing/state.ts +21 -0
- package/src/testing/store.ts +26 -0
- package/src/testing/subscription.ts +38 -0
- package/src/testing/tax-category.ts +27 -0
- package/src/testing/type.ts +9 -6
- package/src/testing/zone.ts +22 -0
- package/src/validate.test.ts +122 -0
- package/src/validate.ts +78 -7
- package/src/.env +0 -0
|
@@ -12,7 +12,7 @@ describe("Subscription Repository", () => {
|
|
|
12
12
|
const config: Config = { storage, strict: false };
|
|
13
13
|
const repository = new SubscriptionRepository(config);
|
|
14
14
|
|
|
15
|
-
test("create subscription with SQS destination", () => {
|
|
15
|
+
test("create subscription with SQS destination", async () => {
|
|
16
16
|
const draft: SubscriptionDraft = {
|
|
17
17
|
key: "test-subscription",
|
|
18
18
|
destination: {
|
|
@@ -30,7 +30,7 @@ describe("Subscription Repository", () => {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
const ctx = { projectKey: "dummy" };
|
|
33
|
-
const result = repository.create(ctx, draft);
|
|
33
|
+
const result = await repository.create(ctx, draft);
|
|
34
34
|
|
|
35
35
|
expect(result.id).toBeDefined();
|
|
36
36
|
expect(result.version).toBe(1);
|
|
@@ -43,12 +43,12 @@ describe("Subscription Repository", () => {
|
|
|
43
43
|
expect(result.events).toEqual([]);
|
|
44
44
|
|
|
45
45
|
// Test that the subscription is stored
|
|
46
|
-
const items = repository.query(ctx);
|
|
46
|
+
const items = await repository.query(ctx);
|
|
47
47
|
expect(items.count).toBe(1);
|
|
48
48
|
expect(items.results[0].id).toBe(result.id);
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
test("create subscription with Google Cloud Pub/Sub destination", () => {
|
|
51
|
+
test("create subscription with Google Cloud Pub/Sub destination", async () => {
|
|
52
52
|
const draft: SubscriptionDraft = {
|
|
53
53
|
key: "pubsub-subscription",
|
|
54
54
|
destination: {
|
|
@@ -69,7 +69,7 @@ describe("Subscription Repository", () => {
|
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
const ctx = { projectKey: "dummy" };
|
|
72
|
-
const result = repository.create(ctx, draft);
|
|
72
|
+
const result = await repository.create(ctx, draft);
|
|
73
73
|
|
|
74
74
|
expect(result.id).toBeDefined();
|
|
75
75
|
expect(result.key).toBe(draft.key);
|
|
@@ -79,7 +79,7 @@ describe("Subscription Repository", () => {
|
|
|
79
79
|
expect(result.status).toBe("Healthy");
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
-
test("create subscription with Azure Event Grid destination", () => {
|
|
82
|
+
test("create subscription with Azure Event Grid destination", async () => {
|
|
83
83
|
const draft: SubscriptionDraft = {
|
|
84
84
|
key: "azure-subscription",
|
|
85
85
|
destination: {
|
|
@@ -96,7 +96,7 @@ describe("Subscription Repository", () => {
|
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
const ctx = { projectKey: "dummy" };
|
|
99
|
-
const result = repository.create(ctx, draft);
|
|
99
|
+
const result = await repository.create(ctx, draft);
|
|
100
100
|
|
|
101
101
|
expect(result.id).toBeDefined();
|
|
102
102
|
expect(result.key).toBe(draft.key);
|
|
@@ -105,7 +105,7 @@ describe("Subscription Repository", () => {
|
|
|
105
105
|
expect(result.status).toBe("Healthy");
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
test("create subscription with Azure Service Bus destination", () => {
|
|
108
|
+
test("create subscription with Azure Service Bus destination", async () => {
|
|
109
109
|
const draft: SubscriptionDraft = {
|
|
110
110
|
key: "servicebus-subscription",
|
|
111
111
|
destination: {
|
|
@@ -116,7 +116,7 @@ describe("Subscription Repository", () => {
|
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
const ctx = { projectKey: "dummy" };
|
|
119
|
-
const result = repository.create(ctx, draft);
|
|
119
|
+
const result = await repository.create(ctx, draft);
|
|
120
120
|
|
|
121
121
|
expect(result.id).toBeDefined();
|
|
122
122
|
expect(result.key).toBe(draft.key);
|
|
@@ -124,7 +124,7 @@ describe("Subscription Repository", () => {
|
|
|
124
124
|
expect(result.status).toBe("Healthy");
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
-
test("create subscription fails with invalid SQS account ID", () => {
|
|
127
|
+
test("create subscription fails with invalid SQS account ID", async () => {
|
|
128
128
|
const draft: SubscriptionDraft = {
|
|
129
129
|
key: "invalid-subscription",
|
|
130
130
|
destination: {
|
|
@@ -138,12 +138,12 @@ describe("Subscription Repository", () => {
|
|
|
138
138
|
|
|
139
139
|
const ctx = { projectKey: "dummy" };
|
|
140
140
|
|
|
141
|
-
expect(()
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
await expect(repository.create(ctx, draft)).rejects.toThrow(
|
|
142
|
+
"A test message could not be delivered to this destination",
|
|
143
|
+
);
|
|
144
144
|
});
|
|
145
145
|
|
|
146
|
-
test("update subscription - setKey", () => {
|
|
146
|
+
test("update subscription - setKey", async () => {
|
|
147
147
|
const draft: SubscriptionDraft = {
|
|
148
148
|
key: "test-subscription-update",
|
|
149
149
|
destination: {
|
|
@@ -154,9 +154,9 @@ describe("Subscription Repository", () => {
|
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
const ctx = { projectKey: "dummy" };
|
|
157
|
-
const subscription = repository.create(ctx, draft);
|
|
157
|
+
const subscription = await repository.create(ctx, draft);
|
|
158
158
|
|
|
159
|
-
const result = repository.processUpdateActions(
|
|
159
|
+
const result = await repository.processUpdateActions(
|
|
160
160
|
ctx,
|
|
161
161
|
subscription,
|
|
162
162
|
subscription.version,
|
|
@@ -172,7 +172,7 @@ describe("Subscription Repository", () => {
|
|
|
172
172
|
expect(result.version).toBe(subscription.version + 1);
|
|
173
173
|
});
|
|
174
174
|
|
|
175
|
-
test("get and delete subscription", () => {
|
|
175
|
+
test("get and delete subscription", async () => {
|
|
176
176
|
const draft: SubscriptionDraft = {
|
|
177
177
|
key: "delete-test",
|
|
178
178
|
destination: {
|
|
@@ -183,25 +183,25 @@ describe("Subscription Repository", () => {
|
|
|
183
183
|
};
|
|
184
184
|
|
|
185
185
|
const ctx = { projectKey: "dummy" };
|
|
186
|
-
const subscription = repository.create(ctx, draft);
|
|
186
|
+
const subscription = await repository.create(ctx, draft);
|
|
187
187
|
|
|
188
188
|
// Test get
|
|
189
|
-
const retrieved = repository.get(ctx, subscription.id);
|
|
189
|
+
const retrieved = await repository.get(ctx, subscription.id);
|
|
190
190
|
expect(retrieved).toBeDefined();
|
|
191
191
|
expect(retrieved?.id).toBe(subscription.id);
|
|
192
192
|
|
|
193
193
|
// Test getByKey
|
|
194
|
-
const retrievedByKey = repository.getByKey(ctx, subscription.key!);
|
|
194
|
+
const retrievedByKey = await repository.getByKey(ctx, subscription.key!);
|
|
195
195
|
expect(retrievedByKey).toBeDefined();
|
|
196
196
|
expect(retrievedByKey?.key).toBe(subscription.key);
|
|
197
197
|
|
|
198
198
|
// Test delete
|
|
199
|
-
const deleted = repository.delete(ctx, subscription.id);
|
|
199
|
+
const deleted = await repository.delete(ctx, subscription.id);
|
|
200
200
|
expect(deleted).toBeDefined();
|
|
201
201
|
expect(deleted?.id).toBe(subscription.id);
|
|
202
202
|
|
|
203
203
|
// Verify it's deleted
|
|
204
|
-
const notFound = repository.get(ctx, subscription.id);
|
|
204
|
+
const notFound = await repository.get(ctx, subscription.id);
|
|
205
205
|
expect(notFound).toBeNull();
|
|
206
206
|
});
|
|
207
207
|
});
|
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
} from "@commercetools/platform-sdk";
|
|
8
8
|
import type { Config } from "#src/config.ts";
|
|
9
9
|
import { CommercetoolsError } from "#src/exceptions.ts";
|
|
10
|
+
import { SubscriptionDraftSchema } from "#src/schemas/generated/subscription.ts";
|
|
10
11
|
import { getBaseResourceProperties } from "../helpers.ts";
|
|
11
12
|
import type { Writable } from "../types.ts";
|
|
12
13
|
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract.ts";
|
|
@@ -19,9 +20,13 @@ export class SubscriptionRepository extends AbstractResourceRepository<"subscrip
|
|
|
19
20
|
constructor(config: Config) {
|
|
20
21
|
super("subscription", config);
|
|
21
22
|
this.actions = new SubscriptionUpdateHandler(config.storage);
|
|
23
|
+
this.draftSchema = SubscriptionDraftSchema;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
create(
|
|
26
|
+
async create(
|
|
27
|
+
context: RepositoryContext,
|
|
28
|
+
draft: SubscriptionDraft,
|
|
29
|
+
): Promise<Subscription> {
|
|
25
30
|
// TODO: We could actually test this here by using the aws sdk. For now
|
|
26
31
|
// hardcode a failed check when account id is 0000000000
|
|
27
32
|
if (draft.destination.type === "SQS") {
|
|
@@ -40,7 +45,7 @@ export class SubscriptionRepository extends AbstractResourceRepository<"subscrip
|
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
const resource: Subscription = {
|
|
43
|
-
...getBaseResourceProperties(),
|
|
48
|
+
...getBaseResourceProperties(context.clientId),
|
|
44
49
|
changes: draft.changes || [],
|
|
45
50
|
destination: draft.destination,
|
|
46
51
|
format: draft.format || {
|
|
@@ -51,7 +56,7 @@ export class SubscriptionRepository extends AbstractResourceRepository<"subscrip
|
|
|
51
56
|
status: "Healthy",
|
|
52
57
|
events: draft.events || [],
|
|
53
58
|
};
|
|
54
|
-
return this.saveNew(context, resource);
|
|
59
|
+
return await this.saveNew(context, resource);
|
|
55
60
|
}
|
|
56
61
|
}
|
|
57
62
|
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
} from "@commercetools/platform-sdk";
|
|
5
5
|
import type { Config } from "#src/config.ts";
|
|
6
6
|
import { getBaseResourceProperties } from "#src/helpers.ts";
|
|
7
|
+
import { TaxCategoryDraftSchema } from "#src/schemas/generated/tax-category.ts";
|
|
7
8
|
import type { RepositoryContext } from "../abstract.ts";
|
|
8
9
|
import { AbstractResourceRepository } from "../abstract.ts";
|
|
9
10
|
import { TaxCategoryUpdateHandler } from "./actions.ts";
|
|
@@ -13,14 +14,18 @@ export class TaxCategoryRepository extends AbstractResourceRepository<"tax-categ
|
|
|
13
14
|
constructor(config: Config) {
|
|
14
15
|
super("tax-category", config);
|
|
15
16
|
this.actions = new TaxCategoryUpdateHandler(this._storage);
|
|
17
|
+
this.draftSchema = TaxCategoryDraftSchema;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
create(
|
|
20
|
+
async create(
|
|
21
|
+
context: RepositoryContext,
|
|
22
|
+
draft: TaxCategoryDraft,
|
|
23
|
+
): Promise<TaxCategory> {
|
|
19
24
|
const resource: TaxCategory = {
|
|
20
|
-
...getBaseResourceProperties(),
|
|
25
|
+
...getBaseResourceProperties(context.clientId),
|
|
21
26
|
...draft,
|
|
22
27
|
rates: draft.rates?.map(taxRateFromTaxRateDraft) || [],
|
|
23
28
|
};
|
|
24
|
-
return this.saveNew(context, resource);
|
|
29
|
+
return await this.saveNew(context, resource);
|
|
25
30
|
}
|
|
26
31
|
}
|
|
@@ -47,7 +47,13 @@ export class TypeUpdateHandler
|
|
|
47
47
|
) {
|
|
48
48
|
field.type.elementType.values.push(value);
|
|
49
49
|
} else {
|
|
50
|
-
throw new
|
|
50
|
+
throw new CommercetoolsError<InvalidOperationError>(
|
|
51
|
+
{
|
|
52
|
+
code: "InvalidOperation",
|
|
53
|
+
message: "Type is not a Enum (or Set of Enum)",
|
|
54
|
+
},
|
|
55
|
+
400,
|
|
56
|
+
);
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
59
|
});
|
|
@@ -85,7 +91,13 @@ export class TypeUpdateHandler
|
|
|
85
91
|
}
|
|
86
92
|
});
|
|
87
93
|
} else {
|
|
88
|
-
throw new
|
|
94
|
+
throw new CommercetoolsError<InvalidOperationError>(
|
|
95
|
+
{
|
|
96
|
+
code: "InvalidOperation",
|
|
97
|
+
message: "Type is not a Enum (or Set of Enum)",
|
|
98
|
+
},
|
|
99
|
+
400,
|
|
100
|
+
);
|
|
89
101
|
}
|
|
90
102
|
}
|
|
91
103
|
});
|
|
@@ -105,7 +117,13 @@ export class TypeUpdateHandler
|
|
|
105
117
|
fieldNames.forEach((fieldName) => {
|
|
106
118
|
const field = fields.get(fieldName);
|
|
107
119
|
if (field === undefined) {
|
|
108
|
-
throw new
|
|
120
|
+
throw new CommercetoolsError<InvalidOperationError>(
|
|
121
|
+
{
|
|
122
|
+
code: "InvalidOperation",
|
|
123
|
+
message: "Adding new field definitions is not fully supported yet",
|
|
124
|
+
},
|
|
125
|
+
400,
|
|
126
|
+
);
|
|
109
127
|
}
|
|
110
128
|
result.push(field);
|
|
111
129
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Type, TypeDraft } from "@commercetools/platform-sdk";
|
|
2
2
|
import type { Config } from "#src/config.ts";
|
|
3
3
|
import { getBaseResourceProperties } from "#src/helpers.ts";
|
|
4
|
+
import { TypeDraftSchema } from "#src/schemas/generated/type.ts";
|
|
4
5
|
import type { RepositoryContext } from "../abstract.ts";
|
|
5
6
|
import { AbstractResourceRepository } from "../abstract.ts";
|
|
6
7
|
import { TypeUpdateHandler } from "./actions.ts";
|
|
@@ -9,17 +10,18 @@ export class TypeRepository extends AbstractResourceRepository<"type"> {
|
|
|
9
10
|
constructor(config: Config) {
|
|
10
11
|
super("type", config);
|
|
11
12
|
this.actions = new TypeUpdateHandler(config.storage);
|
|
13
|
+
this.draftSchema = TypeDraftSchema;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
create(context: RepositoryContext, draft: TypeDraft): Type {
|
|
16
|
+
async create(context: RepositoryContext, draft: TypeDraft): Promise<Type> {
|
|
15
17
|
const resource: Type = {
|
|
16
|
-
...getBaseResourceProperties(),
|
|
18
|
+
...getBaseResourceProperties(context.clientId),
|
|
17
19
|
key: draft.key,
|
|
18
20
|
name: draft.name,
|
|
19
21
|
resourceTypeIds: draft.resourceTypeIds,
|
|
20
22
|
fieldDefinitions: draft.fieldDefinitions || [],
|
|
21
23
|
description: draft.description,
|
|
22
24
|
};
|
|
23
|
-
return this.saveNew(context, resource);
|
|
25
|
+
return await this.saveNew(context, resource);
|
|
24
26
|
}
|
|
25
27
|
}
|
|
@@ -16,7 +16,7 @@ describe("Zone Repository", () => {
|
|
|
16
16
|
const config: Config = { storage, strict: false };
|
|
17
17
|
const repository = new ZoneRepository(config);
|
|
18
18
|
|
|
19
|
-
test("create zone", () => {
|
|
19
|
+
test("create zone", async () => {
|
|
20
20
|
const draft: ZoneDraft = {
|
|
21
21
|
key: "europe-zone",
|
|
22
22
|
name: "Europe Zone",
|
|
@@ -32,7 +32,7 @@ describe("Zone Repository", () => {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
const ctx = { projectKey: "dummy" };
|
|
35
|
-
const result = repository.create(ctx, draft);
|
|
35
|
+
const result = await repository.create(ctx, draft);
|
|
36
36
|
|
|
37
37
|
expect(result.id).toBeDefined();
|
|
38
38
|
expect(result.version).toBe(1);
|
|
@@ -42,18 +42,18 @@ describe("Zone Repository", () => {
|
|
|
42
42
|
expect(result.locations).toEqual(draft.locations);
|
|
43
43
|
|
|
44
44
|
// Test that the zone is stored
|
|
45
|
-
const items = repository.query(ctx);
|
|
45
|
+
const items = await repository.query(ctx);
|
|
46
46
|
expect(items.count).toBe(1);
|
|
47
47
|
expect(items.results[0].id).toBe(result.id);
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
test("create zone without optional fields", () => {
|
|
50
|
+
test("create zone without optional fields", async () => {
|
|
51
51
|
const draft: ZoneDraft = {
|
|
52
52
|
name: "Simple Zone",
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
const ctx = { projectKey: "dummy" };
|
|
56
|
-
const result = repository.create(ctx, draft);
|
|
56
|
+
const result = await repository.create(ctx, draft);
|
|
57
57
|
|
|
58
58
|
expect(result.id).toBeDefined();
|
|
59
59
|
expect(result.name).toBe(draft.name);
|
|
@@ -62,67 +62,82 @@ describe("Zone Repository", () => {
|
|
|
62
62
|
expect(result.locations).toEqual([]);
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
test("update zone - changeName", () => {
|
|
65
|
+
test("update zone - changeName", async () => {
|
|
66
66
|
const draft: ZoneDraft = {
|
|
67
67
|
key: "test-zone",
|
|
68
68
|
name: "Test Zone",
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
const ctx = { projectKey: "dummy" };
|
|
72
|
-
const zone = repository.create(ctx, draft);
|
|
72
|
+
const zone = await repository.create(ctx, draft);
|
|
73
73
|
|
|
74
|
-
const result = repository.processUpdateActions(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
const result = await repository.processUpdateActions(
|
|
75
|
+
ctx,
|
|
76
|
+
zone,
|
|
77
|
+
zone.version,
|
|
78
|
+
[
|
|
79
|
+
{
|
|
80
|
+
action: "changeName",
|
|
81
|
+
name: "Updated Test Zone",
|
|
82
|
+
} as ZoneChangeNameAction,
|
|
83
|
+
],
|
|
84
|
+
);
|
|
80
85
|
|
|
81
86
|
expect(result.name).toBe("Updated Test Zone");
|
|
82
87
|
expect(result.version).toBe(zone.version + 1);
|
|
83
88
|
});
|
|
84
89
|
|
|
85
|
-
test("update zone - setKey", () => {
|
|
90
|
+
test("update zone - setKey", async () => {
|
|
86
91
|
const draft: ZoneDraft = {
|
|
87
92
|
key: "test-zone-2",
|
|
88
93
|
name: "Test Zone 2",
|
|
89
94
|
};
|
|
90
95
|
|
|
91
96
|
const ctx = { projectKey: "dummy" };
|
|
92
|
-
const zone = repository.create(ctx, draft);
|
|
97
|
+
const zone = await repository.create(ctx, draft);
|
|
93
98
|
|
|
94
|
-
const result = repository.processUpdateActions(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
const result = await repository.processUpdateActions(
|
|
100
|
+
ctx,
|
|
101
|
+
zone,
|
|
102
|
+
zone.version,
|
|
103
|
+
[
|
|
104
|
+
{
|
|
105
|
+
action: "setKey",
|
|
106
|
+
key: "new-zone-key",
|
|
107
|
+
} as ZoneSetKeyAction,
|
|
108
|
+
],
|
|
109
|
+
);
|
|
100
110
|
|
|
101
111
|
expect(result.key).toBe("new-zone-key");
|
|
102
112
|
expect(result.version).toBe(zone.version + 1);
|
|
103
113
|
});
|
|
104
114
|
|
|
105
|
-
test("update zone - setDescription", () => {
|
|
115
|
+
test("update zone - setDescription", async () => {
|
|
106
116
|
const draft: ZoneDraft = {
|
|
107
117
|
key: "test-zone-3",
|
|
108
118
|
name: "Test Zone 3",
|
|
109
119
|
};
|
|
110
120
|
|
|
111
121
|
const ctx = { projectKey: "dummy" };
|
|
112
|
-
const zone = repository.create(ctx, draft);
|
|
122
|
+
const zone = await repository.create(ctx, draft);
|
|
113
123
|
|
|
114
|
-
const result = repository.processUpdateActions(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
const result = await repository.processUpdateActions(
|
|
125
|
+
ctx,
|
|
126
|
+
zone,
|
|
127
|
+
zone.version,
|
|
128
|
+
[
|
|
129
|
+
{
|
|
130
|
+
action: "setDescription",
|
|
131
|
+
description: "New zone description",
|
|
132
|
+
} as ZoneSetDescriptionAction,
|
|
133
|
+
],
|
|
134
|
+
);
|
|
120
135
|
|
|
121
136
|
expect(result.description).toBe("New zone description");
|
|
122
137
|
expect(result.version).toBe(zone.version + 1);
|
|
123
138
|
});
|
|
124
139
|
|
|
125
|
-
test("update zone - addLocation", () => {
|
|
140
|
+
test("update zone - addLocation", async () => {
|
|
126
141
|
const draft: ZoneDraft = {
|
|
127
142
|
key: "test-zone-4",
|
|
128
143
|
name: "Test Zone 4",
|
|
@@ -134,16 +149,21 @@ describe("Zone Repository", () => {
|
|
|
134
149
|
};
|
|
135
150
|
|
|
136
151
|
const ctx = { projectKey: "dummy" };
|
|
137
|
-
const zone = repository.create(ctx, draft);
|
|
152
|
+
const zone = await repository.create(ctx, draft);
|
|
138
153
|
|
|
139
|
-
const result = repository.processUpdateActions(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
154
|
+
const result = await repository.processUpdateActions(
|
|
155
|
+
ctx,
|
|
156
|
+
zone,
|
|
157
|
+
zone.version,
|
|
158
|
+
[
|
|
159
|
+
{
|
|
160
|
+
action: "addLocation",
|
|
161
|
+
location: {
|
|
162
|
+
country: "FR",
|
|
163
|
+
},
|
|
164
|
+
} as ZoneAddLocationAction,
|
|
165
|
+
],
|
|
166
|
+
);
|
|
147
167
|
|
|
148
168
|
expect(result.locations).toHaveLength(2);
|
|
149
169
|
expect(result.locations).toContainEqual({ country: "DE" });
|
|
@@ -151,7 +171,7 @@ describe("Zone Repository", () => {
|
|
|
151
171
|
expect(result.version).toBe(zone.version + 1);
|
|
152
172
|
});
|
|
153
173
|
|
|
154
|
-
test("update zone - addLocation with state", () => {
|
|
174
|
+
test("update zone - addLocation with state", async () => {
|
|
155
175
|
const draft: ZoneDraft = {
|
|
156
176
|
key: "test-zone-5",
|
|
157
177
|
name: "Test Zone 5",
|
|
@@ -159,24 +179,29 @@ describe("Zone Repository", () => {
|
|
|
159
179
|
};
|
|
160
180
|
|
|
161
181
|
const ctx = { projectKey: "dummy" };
|
|
162
|
-
const zone = repository.create(ctx, draft);
|
|
182
|
+
const zone = await repository.create(ctx, draft);
|
|
163
183
|
|
|
164
|
-
const result = repository.processUpdateActions(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
184
|
+
const result = await repository.processUpdateActions(
|
|
185
|
+
ctx,
|
|
186
|
+
zone,
|
|
187
|
+
zone.version,
|
|
188
|
+
[
|
|
189
|
+
{
|
|
190
|
+
action: "addLocation",
|
|
191
|
+
location: {
|
|
192
|
+
country: "US",
|
|
193
|
+
state: "CA",
|
|
194
|
+
},
|
|
195
|
+
} as ZoneAddLocationAction,
|
|
196
|
+
],
|
|
197
|
+
);
|
|
173
198
|
|
|
174
199
|
expect(result.locations).toHaveLength(1);
|
|
175
200
|
expect(result.locations[0]).toEqual({ country: "US", state: "CA" });
|
|
176
201
|
expect(result.version).toBe(zone.version + 1);
|
|
177
202
|
});
|
|
178
203
|
|
|
179
|
-
test("update zone - removeLocation", () => {
|
|
204
|
+
test("update zone - removeLocation", async () => {
|
|
180
205
|
const draft: ZoneDraft = {
|
|
181
206
|
key: "test-zone-6",
|
|
182
207
|
name: "Test Zone 6",
|
|
@@ -195,16 +220,21 @@ describe("Zone Repository", () => {
|
|
|
195
220
|
};
|
|
196
221
|
|
|
197
222
|
const ctx = { projectKey: "dummy" };
|
|
198
|
-
const zone = repository.create(ctx, draft);
|
|
223
|
+
const zone = await repository.create(ctx, draft);
|
|
199
224
|
|
|
200
|
-
const result = repository.processUpdateActions(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
225
|
+
const result = await repository.processUpdateActions(
|
|
226
|
+
ctx,
|
|
227
|
+
zone,
|
|
228
|
+
zone.version,
|
|
229
|
+
[
|
|
230
|
+
{
|
|
231
|
+
action: "removeLocation",
|
|
232
|
+
location: {
|
|
233
|
+
country: "FR",
|
|
234
|
+
},
|
|
235
|
+
} as ZoneRemoveLocationAction,
|
|
236
|
+
],
|
|
237
|
+
);
|
|
208
238
|
|
|
209
239
|
expect(result.locations).toHaveLength(2);
|
|
210
240
|
expect(result.locations).toContainEqual({ country: "DE" });
|
|
@@ -213,7 +243,7 @@ describe("Zone Repository", () => {
|
|
|
213
243
|
expect(result.version).toBe(zone.version + 1);
|
|
214
244
|
});
|
|
215
245
|
|
|
216
|
-
test("update zone - removeLocation with state", () => {
|
|
246
|
+
test("update zone - removeLocation with state", async () => {
|
|
217
247
|
const draft: ZoneDraft = {
|
|
218
248
|
key: "test-zone-7",
|
|
219
249
|
name: "Test Zone 7",
|
|
@@ -230,49 +260,54 @@ describe("Zone Repository", () => {
|
|
|
230
260
|
};
|
|
231
261
|
|
|
232
262
|
const ctx = { projectKey: "dummy" };
|
|
233
|
-
const zone = repository.create(ctx, draft);
|
|
263
|
+
const zone = await repository.create(ctx, draft);
|
|
234
264
|
|
|
235
|
-
const result = repository.processUpdateActions(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
265
|
+
const result = await repository.processUpdateActions(
|
|
266
|
+
ctx,
|
|
267
|
+
zone,
|
|
268
|
+
zone.version,
|
|
269
|
+
[
|
|
270
|
+
{
|
|
271
|
+
action: "removeLocation",
|
|
272
|
+
location: {
|
|
273
|
+
country: "US",
|
|
274
|
+
state: "CA",
|
|
275
|
+
},
|
|
276
|
+
} as ZoneRemoveLocationAction,
|
|
277
|
+
],
|
|
278
|
+
);
|
|
244
279
|
|
|
245
280
|
expect(result.locations).toHaveLength(1);
|
|
246
281
|
expect(result.locations[0]).toEqual({ country: "US", state: "NY" });
|
|
247
282
|
expect(result.version).toBe(zone.version + 1);
|
|
248
283
|
});
|
|
249
284
|
|
|
250
|
-
test("get and delete zone", () => {
|
|
285
|
+
test("get and delete zone", async () => {
|
|
251
286
|
const draft: ZoneDraft = {
|
|
252
287
|
key: "delete-test",
|
|
253
288
|
name: "Delete Test Zone",
|
|
254
289
|
};
|
|
255
290
|
|
|
256
291
|
const ctx = { projectKey: "dummy" };
|
|
257
|
-
const zone = repository.create(ctx, draft);
|
|
292
|
+
const zone = await repository.create(ctx, draft);
|
|
258
293
|
|
|
259
294
|
// Test get
|
|
260
|
-
const retrieved = repository.get(ctx, zone.id);
|
|
295
|
+
const retrieved = await repository.get(ctx, zone.id);
|
|
261
296
|
expect(retrieved).toBeDefined();
|
|
262
297
|
expect(retrieved?.id).toBe(zone.id);
|
|
263
298
|
|
|
264
299
|
// Test getByKey
|
|
265
|
-
const retrievedByKey = repository.getByKey(ctx, zone.key!);
|
|
300
|
+
const retrievedByKey = await repository.getByKey(ctx, zone.key!);
|
|
266
301
|
expect(retrievedByKey).toBeDefined();
|
|
267
302
|
expect(retrievedByKey?.key).toBe(zone.key);
|
|
268
303
|
|
|
269
304
|
// Test delete
|
|
270
|
-
const deleted = repository.delete(ctx, zone.id);
|
|
305
|
+
const deleted = await repository.delete(ctx, zone.id);
|
|
271
306
|
expect(deleted).toBeDefined();
|
|
272
307
|
expect(deleted?.id).toBe(zone.id);
|
|
273
308
|
|
|
274
309
|
// Verify it's deleted
|
|
275
|
-
const notFound = repository.get(ctx, zone.id);
|
|
310
|
+
const notFound = await repository.get(ctx, zone.id);
|
|
276
311
|
expect(notFound).toBeNull();
|
|
277
312
|
});
|
|
278
313
|
});
|
package/src/repositories/zone.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
ZoneUpdateAction,
|
|
10
10
|
} from "@commercetools/platform-sdk";
|
|
11
11
|
import type { Config } from "#src/config.ts";
|
|
12
|
+
import { ZoneDraftSchema } from "#src/schemas/generated/zone.ts";
|
|
12
13
|
import { getBaseResourceProperties } from "../helpers.ts";
|
|
13
14
|
import type { Writable } from "../types.ts";
|
|
14
15
|
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract.ts";
|
|
@@ -21,17 +22,18 @@ export class ZoneRepository extends AbstractResourceRepository<"zone"> {
|
|
|
21
22
|
constructor(config: Config) {
|
|
22
23
|
super("zone", config);
|
|
23
24
|
this.actions = new ZoneUpdateHandler(config.storage);
|
|
25
|
+
this.draftSchema = ZoneDraftSchema;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
create(context: RepositoryContext, draft: ZoneDraft): Zone {
|
|
28
|
+
async create(context: RepositoryContext, draft: ZoneDraft): Promise<Zone> {
|
|
27
29
|
const resource: Zone = {
|
|
28
|
-
...getBaseResourceProperties(),
|
|
30
|
+
...getBaseResourceProperties(context.clientId),
|
|
29
31
|
key: draft.key,
|
|
30
32
|
locations: draft.locations || [],
|
|
31
33
|
name: draft.name,
|
|
32
34
|
description: draft.description,
|
|
33
35
|
};
|
|
34
|
-
return this.saveNew(context, resource);
|
|
36
|
+
return await this.saveNew(context, resource);
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This file is auto-generated by scripts/generate-schemas.ts
|
|
2
|
+
// Do not edit manually.
|
|
3
|
+
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { CustomFieldsDraftSchema, PermissionSchema } from "./common.ts";
|
|
6
|
+
|
|
7
|
+
export const AssociateRoleDraftSchema = z.object({
|
|
8
|
+
key: z.string(),
|
|
9
|
+
name: z.string().optional(),
|
|
10
|
+
buyerAssignable: z.boolean().optional(),
|
|
11
|
+
permissions: z.array(PermissionSchema).optional(),
|
|
12
|
+
custom: CustomFieldsDraftSchema.optional(),
|
|
13
|
+
});
|