@stripe/extensibility-dev-tools 0.23.5 → 0.24.2
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 +28 -0
- package/dist/bin/build-custom-object-definitions.cjs +42 -36
- package/dist/bin/build-custom-object-definitions.js +42 -36
- package/dist/bin/create-upload-image.cjs +42 -36
- package/dist/bin/create-upload-image.js +42 -36
- package/dist/bin/dev-tools-rpc.cjs +42 -31
- package/dist/bin/dev-tools-rpc.js +42 -31
- package/dist/bin/gen-workspace.cjs +42 -31
- package/dist/bin/gen-workspace.js +42 -31
- package/dist/bin/template-info.cjs +28 -30
- package/dist/bin/template-info.js +28 -30
- package/dist/custom-objects/to-proto-json.d.ts +2 -1
- package/dist/custom-objects/to-proto-json.d.ts.map +1 -1
- package/dist/index.cjs +42 -31
- package/dist/index.js +42 -31
- package/dist/templates/extensions/base.d.ts +1 -1
- package/dist/templates/extensions/base.d.ts.map +1 -1
- package/dist/templates/extensions/core.workflows.custom_action.d.ts.map +1 -1
- package/dist/templates/index.cjs +42 -31
- package/dist/templates/index.js +42 -31
- package/dist/templates/root/index.d.ts.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/workspace/index.cjs +42 -31
- package/dist/workspace/index.js +42 -31
- package/package.json +4 -4
- package/templates/extensions/billing.bill.discount_calculation/index.ts +2 -3
- package/templates/extensions/billing.customer_balance_application/index.test.ts +5 -5
- package/templates/extensions/billing.customer_balance_application/index.ts +4 -4
- package/templates/extensions/billing.invoice_collection_setting/index.ts +2 -2
- package/templates/extensions/billing.prorations/index.ts +2 -2
- package/templates/extensions/billing.recurring_billing_item_handling/index.ts +2 -2
- package/templates/extensions/core.workflows.custom_action/index.ts +2 -3
- package/templates/extensions/extend.workflows.custom_action/index.ts +2 -3
- package/templates/root/custom-objects/{package.json → package.json.mustache} +4 -4
- package/dist/extensibility-dev-tools-alpha.d.ts +0 -199
- package/dist/extensibility-dev-tools-beta.d.ts +0 -199
- package/dist/extensibility-dev-tools-dependencies-alpha.d.ts +0 -51
- package/dist/extensibility-dev-tools-dependencies-beta.d.ts +0 -51
- package/dist/extensibility-dev-tools-dependencies-internal.d.ts +0 -372
- package/dist/extensibility-dev-tools-dependencies-public.d.ts +0 -51
- package/dist/extensibility-dev-tools-internal.d.ts +0 -1722
- package/dist/extensibility-dev-tools-jsonschema-tools-alpha.d.ts +0 -57
- package/dist/extensibility-dev-tools-jsonschema-tools-beta.d.ts +0 -57
- package/dist/extensibility-dev-tools-jsonschema-tools-internal.d.ts +0 -123
- package/dist/extensibility-dev-tools-jsonschema-tools-public.d.ts +0 -57
- package/dist/extensibility-dev-tools-manifest-alpha.d.ts +0 -31
- package/dist/extensibility-dev-tools-manifest-beta.d.ts +0 -31
- package/dist/extensibility-dev-tools-manifest-internal.d.ts +0 -461
- package/dist/extensibility-dev-tools-manifest-public.d.ts +0 -31
- package/dist/extensibility-dev-tools-public.d.ts +0 -199
- package/dist/extensibility-dev-tools-schemas-alpha.d.ts +0 -9
- package/dist/extensibility-dev-tools-schemas-beta.d.ts +0 -9
- package/dist/extensibility-dev-tools-schemas-internal.d.ts +0 -41
- package/dist/extensibility-dev-tools-schemas-public.d.ts +0 -9
- package/dist/extensibility-dev-tools-templates-alpha.d.ts +0 -67
- package/dist/extensibility-dev-tools-templates-beta.d.ts +0 -67
- package/dist/extensibility-dev-tools-templates-internal.d.ts +0 -554
- package/dist/extensibility-dev-tools-templates-public.d.ts +0 -67
- package/dist/extensibility-dev-tools-workspace-alpha.d.ts +0 -51
- package/dist/extensibility-dev-tools-workspace-beta.d.ts +0 -51
- package/dist/extensibility-dev-tools-workspace-internal.d.ts +0 -410
- package/dist/extensibility-dev-tools-workspace-public.d.ts +0 -51
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @stripe/extensibility-dev-tools
|
|
2
|
+
|
|
3
|
+
Development toolkit for Stripe Apps. Provides template generation, manifest parsing, workspace management, schema handling, and CLI tools.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @stripe/extensibility-dev-tools
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## CLI tools
|
|
12
|
+
|
|
13
|
+
| Command | Description |
|
|
14
|
+
| --------------- | ------------------------------------------- |
|
|
15
|
+
| `gen-workspace` | Generate a Stripe Apps workspace |
|
|
16
|
+
| `gen-schemas` | Generate schemas from extension definitions |
|
|
17
|
+
|
|
18
|
+
## Subpath exports
|
|
19
|
+
|
|
20
|
+
| Subpath | Description |
|
|
21
|
+
| -------------------------------------------------- | ------------------------------------ |
|
|
22
|
+
| `@stripe/extensibility-dev-tools` | Main entry (re-exports below) |
|
|
23
|
+
| `@stripe/extensibility-dev-tools/templates` | Template generation system |
|
|
24
|
+
| `@stripe/extensibility-dev-tools/dependencies` | Dependency management |
|
|
25
|
+
| `@stripe/extensibility-dev-tools/manifest` | Manifest parsing (`stripe-app.yaml`) |
|
|
26
|
+
| `@stripe/extensibility-dev-tools/workspace` | Workspace regeneration |
|
|
27
|
+
| `@stripe/extensibility-dev-tools/jsonschema-tools` | JSON Schema utilities |
|
|
28
|
+
| `@stripe/extensibility-dev-tools/schemas` | Schema definitions |
|
|
@@ -325,11 +325,10 @@ describe('MyDiscountCalculation', () => {
|
|
|
325
325
|
},
|
|
326
326
|
{
|
|
327
327
|
path: "extensions/billing.bill.discount_calculation/index.ts",
|
|
328
|
-
content: `import type { Billing } from '@stripe/extensibility-sdk
|
|
329
|
-
import type { Context } from '@stripe/extensibility-sdk/extensions';
|
|
328
|
+
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
330
329
|
|
|
331
330
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
332
|
-
interface MyDiscountCalculationConfig
|
|
331
|
+
interface MyDiscountCalculationConfig {}
|
|
333
332
|
|
|
334
333
|
export default class MyDiscountCalculation implements Billing.Bill
|
|
335
334
|
.DiscountCalculation<MyDiscountCalculationConfig> {
|
|
@@ -351,32 +350,32 @@ export default class MyDiscountCalculation implements Billing.Bill
|
|
|
351
350
|
path: "extensions/billing.customer_balance_application/index.test.ts",
|
|
352
351
|
content: `import { beforeEach, describe, it, expect } from 'vitest';
|
|
353
352
|
|
|
354
|
-
import
|
|
353
|
+
import MyBalanceApp from './index.js';
|
|
355
354
|
|
|
356
|
-
describe('
|
|
357
|
-
let instance:
|
|
355
|
+
describe('MyBalanceApp', () => {
|
|
356
|
+
let instance: MyBalanceApp;
|
|
358
357
|
|
|
359
358
|
beforeEach(() => {
|
|
360
|
-
instance = new
|
|
359
|
+
instance = new MyBalanceApp();
|
|
361
360
|
});
|
|
362
361
|
|
|
363
362
|
it('should be constructable', () => {
|
|
364
|
-
expect(instance).toBeInstanceOf(
|
|
363
|
+
expect(instance).toBeInstanceOf(MyBalanceApp);
|
|
365
364
|
});
|
|
366
365
|
});
|
|
367
366
|
`
|
|
368
367
|
},
|
|
369
368
|
{
|
|
370
369
|
path: "extensions/billing.customer_balance_application/index.ts",
|
|
371
|
-
content: `import type { Billing, Context } from '@stripe/extensibility-sdk
|
|
370
|
+
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
372
371
|
|
|
373
372
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
374
|
-
interface
|
|
373
|
+
interface MyBalanceAppConfig {}
|
|
375
374
|
|
|
376
|
-
export default class
|
|
375
|
+
export default class MyBalanceApp implements Billing.CustomerBalanceApplication<MyBalanceAppConfig> {
|
|
377
376
|
computeAppliedCustomerBalance(
|
|
378
377
|
request: Billing.CustomerBalanceApplication.CustomerBalanceApplicationInput,
|
|
379
|
-
_config:
|
|
378
|
+
_config: MyBalanceAppConfig,
|
|
380
379
|
_context: Context
|
|
381
380
|
) {
|
|
382
381
|
// TODO: implement your customer balance logic here
|
|
@@ -409,10 +408,10 @@ describe('MyInvoiceCollectionSetting', () => {
|
|
|
409
408
|
},
|
|
410
409
|
{
|
|
411
410
|
path: "extensions/billing.invoice_collection_setting/index.ts",
|
|
412
|
-
content: `import type { Billing, Context } from '@stripe/extensibility-sdk
|
|
411
|
+
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
413
412
|
|
|
414
413
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
415
|
-
interface MyInvoiceCollectionSettingConfig
|
|
414
|
+
interface MyInvoiceCollectionSettingConfig {}
|
|
416
415
|
|
|
417
416
|
export default class MyInvoiceCollectionSetting implements Billing.InvoiceCollectionSetting<MyInvoiceCollectionSettingConfig> {
|
|
418
417
|
collectionOverride(
|
|
@@ -448,10 +447,10 @@ describe('MyProrations', () => {
|
|
|
448
447
|
},
|
|
449
448
|
{
|
|
450
449
|
path: "extensions/billing.prorations/index.ts",
|
|
451
|
-
content: `import type { Billing, Context } from '@stripe/extensibility-sdk
|
|
450
|
+
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
452
451
|
|
|
453
452
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
454
|
-
interface MyProrationsConfig
|
|
453
|
+
interface MyProrationsConfig {}
|
|
455
454
|
|
|
456
455
|
export default class MyProrations implements Billing.Prorations<MyProrationsConfig> {
|
|
457
456
|
prorateItems(
|
|
@@ -489,10 +488,10 @@ describe('MyRecurringBillingItemHandling', () => {
|
|
|
489
488
|
},
|
|
490
489
|
{
|
|
491
490
|
path: "extensions/billing.recurring_billing_item_handling/index.ts",
|
|
492
|
-
content: `import type { Billing, Context } from '@stripe/extensibility-sdk
|
|
491
|
+
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
493
492
|
|
|
494
493
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
495
|
-
interface MyRecurringBillingItemHandlingConfig
|
|
494
|
+
interface MyRecurringBillingItemHandlingConfig {}
|
|
496
495
|
|
|
497
496
|
export default class MyRecurringBillingItemHandling implements Billing.RecurringBillingItemHandling<MyRecurringBillingItemHandlingConfig> {
|
|
498
497
|
beforeItemCreation(
|
|
@@ -739,11 +738,10 @@ describe('MyCustomAction', () => {
|
|
|
739
738
|
},
|
|
740
739
|
{
|
|
741
740
|
path: "extensions/core.workflows.custom_action/index.ts",
|
|
742
|
-
content: `import type { Core } from '@stripe/extensibility-sdk
|
|
743
|
-
import type { Context } from '@stripe/extensibility-sdk/extensions';
|
|
741
|
+
content: `import type { Core, Context } from '@stripe/extensibility-sdk';
|
|
744
742
|
|
|
745
743
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
746
|
-
interface MyCustomActionConfig
|
|
744
|
+
interface MyCustomActionConfig {}
|
|
747
745
|
|
|
748
746
|
export default class MyCustomAction implements Core.Workflows
|
|
749
747
|
.CustomAction<MyCustomActionConfig> {
|
|
@@ -803,11 +801,10 @@ describe('MyCustomAction', () => {
|
|
|
803
801
|
},
|
|
804
802
|
{
|
|
805
803
|
path: "extensions/extend.workflows.custom_action/index.ts",
|
|
806
|
-
content: `import type { Extend } from '@stripe/extensibility-sdk
|
|
807
|
-
import type { Context } from '@stripe/extensibility-sdk/extensions';
|
|
804
|
+
content: `import type { Extend, Context } from '@stripe/extensibility-sdk';
|
|
808
805
|
|
|
809
806
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
810
|
-
interface MyCustomActionConfig
|
|
807
|
+
interface MyCustomActionConfig {}
|
|
811
808
|
|
|
812
809
|
export default class MyCustomAction implements Extend.Workflows
|
|
813
810
|
.CustomAction<MyCustomActionConfig> {
|
|
@@ -894,7 +891,7 @@ generated
|
|
|
894
891
|
`
|
|
895
892
|
},
|
|
896
893
|
{
|
|
897
|
-
path: "root/custom-objects/package.json",
|
|
894
|
+
path: "root/custom-objects/package.json.mustache",
|
|
898
895
|
content: `{
|
|
899
896
|
"name": "custom-objects",
|
|
900
897
|
"type": "module",
|
|
@@ -907,12 +904,12 @@ generated
|
|
|
907
904
|
"test": "vitest run"
|
|
908
905
|
},
|
|
909
906
|
"dependencies": {
|
|
910
|
-
"@stripe/extensibility-custom-objects": "
|
|
911
|
-
"@stripe/extensibility-sdk": "
|
|
907
|
+
"@stripe/extensibility-custom-objects": "{{ customObjectsVersion }}",
|
|
908
|
+
"@stripe/extensibility-sdk": "{{ sdkVersion }}"
|
|
912
909
|
},
|
|
913
910
|
"devDependencies": {
|
|
914
|
-
"@stripe/extensibility-custom-objects-tools": "
|
|
915
|
-
"@stripe/extensibility-test-helpers": "
|
|
911
|
+
"@stripe/extensibility-custom-objects-tools": "{{ customObjectsToolsVersion }}",
|
|
912
|
+
"@stripe/extensibility-test-helpers": "{{ testHelpersVersion }}"
|
|
916
913
|
}
|
|
917
914
|
}
|
|
918
915
|
`
|
|
@@ -1269,7 +1266,7 @@ function _devNpmDep(name, version) {
|
|
|
1269
1266
|
var import_extensibility_tool_utils6 = require("@stripe/extensibility-tool-utils");
|
|
1270
1267
|
var SDK_PACKAGE_NAME = "@stripe/extensibility-sdk";
|
|
1271
1268
|
var LANGUAGE_SERVER_PACKAGE_NAME = "@stripe/extensibility-language-server";
|
|
1272
|
-
var LANGUAGE_SERVER_PACKAGE_VERSION =
|
|
1269
|
+
var LANGUAGE_SERVER_PACKAGE_VERSION = `^${(0, import_extensibility_tool_utils6._workspaceVersion)(LANGUAGE_SERVER_PACKAGE_NAME)}`;
|
|
1273
1270
|
function _createExtensionEslintConfigFile(params, context) {
|
|
1274
1271
|
const { id, extensionInterfaceId } = params;
|
|
1275
1272
|
const { fs: fs3 } = context;
|
|
@@ -1331,6 +1328,7 @@ function _createBaseOutput(params, context) {
|
|
|
1331
1328
|
// src/templates/extensions/core.workflows.custom_action.ts
|
|
1332
1329
|
var EXTENSION_INTERFACE_ID = "core.workflows.custom_action";
|
|
1333
1330
|
var customActionTemplate = {
|
|
1331
|
+
deprecated: true,
|
|
1334
1332
|
methods: {
|
|
1335
1333
|
execute: { implementation_types: ["script", "remote-function"] },
|
|
1336
1334
|
get_form_state: { implementation_types: ["script", "remote-function"] }
|
|
@@ -1834,7 +1832,12 @@ function toFieldSchema(schema, required) {
|
|
|
1834
1832
|
fieldSchema.valuesPresence = FieldPresence.PRESENT;
|
|
1835
1833
|
}
|
|
1836
1834
|
if (schema.default !== void 0) {
|
|
1837
|
-
|
|
1835
|
+
if (dataType === DataType.ENUM_TYPE && enumValues && (typeof schema.default !== "string" || !enumValues.includes(schema.default))) {
|
|
1836
|
+
throw new Error(
|
|
1837
|
+
`Default value ${JSON.stringify(schema.default)} is not a valid enum value. Expected one of: ${enumValues.join(", ")}`
|
|
1838
|
+
);
|
|
1839
|
+
}
|
|
1840
|
+
fieldSchema.default = toDefaultValue(schema.default, dataType);
|
|
1838
1841
|
}
|
|
1839
1842
|
return fieldSchema;
|
|
1840
1843
|
}
|
|
@@ -1897,19 +1900,22 @@ function toValueBoundary(value) {
|
|
|
1897
1900
|
`ValueBoundary only supports integers, got ${String(value)}. Custom object numeric fields are integer-only.`
|
|
1898
1901
|
);
|
|
1899
1902
|
}
|
|
1900
|
-
return {
|
|
1903
|
+
return { integerBoundary: value };
|
|
1901
1904
|
}
|
|
1902
1905
|
function toDefaultValue(value, dataType) {
|
|
1903
1906
|
if (dataType === DataType.STRING_TYPE && typeof value === "string") {
|
|
1904
|
-
return {
|
|
1907
|
+
return { stringDefault: value };
|
|
1908
|
+
}
|
|
1909
|
+
if (dataType === DataType.ENUM_TYPE && typeof value === "string") {
|
|
1910
|
+
return { stringDefault: value };
|
|
1905
1911
|
}
|
|
1906
1912
|
if (dataType === DataType.INTEGER_TYPE && typeof value === "number") {
|
|
1907
|
-
return {
|
|
1913
|
+
return { integerDefault: value };
|
|
1908
1914
|
}
|
|
1909
1915
|
if (dataType === DataType.BOOLEAN_TYPE && typeof value === "boolean") {
|
|
1910
|
-
return {
|
|
1916
|
+
return { booleanDefault: value };
|
|
1911
1917
|
}
|
|
1912
|
-
return {
|
|
1918
|
+
return {};
|
|
1913
1919
|
}
|
|
1914
1920
|
|
|
1915
1921
|
// src/custom-objects/build-definitions.ts
|
|
@@ -302,11 +302,10 @@ describe('MyDiscountCalculation', () => {
|
|
|
302
302
|
},
|
|
303
303
|
{
|
|
304
304
|
path: "extensions/billing.bill.discount_calculation/index.ts",
|
|
305
|
-
content: `import type { Billing } from '@stripe/extensibility-sdk
|
|
306
|
-
import type { Context } from '@stripe/extensibility-sdk/extensions';
|
|
305
|
+
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
307
306
|
|
|
308
307
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
309
|
-
interface MyDiscountCalculationConfig
|
|
308
|
+
interface MyDiscountCalculationConfig {}
|
|
310
309
|
|
|
311
310
|
export default class MyDiscountCalculation implements Billing.Bill
|
|
312
311
|
.DiscountCalculation<MyDiscountCalculationConfig> {
|
|
@@ -328,32 +327,32 @@ export default class MyDiscountCalculation implements Billing.Bill
|
|
|
328
327
|
path: "extensions/billing.customer_balance_application/index.test.ts",
|
|
329
328
|
content: `import { beforeEach, describe, it, expect } from 'vitest';
|
|
330
329
|
|
|
331
|
-
import
|
|
330
|
+
import MyBalanceApp from './index.js';
|
|
332
331
|
|
|
333
|
-
describe('
|
|
334
|
-
let instance:
|
|
332
|
+
describe('MyBalanceApp', () => {
|
|
333
|
+
let instance: MyBalanceApp;
|
|
335
334
|
|
|
336
335
|
beforeEach(() => {
|
|
337
|
-
instance = new
|
|
336
|
+
instance = new MyBalanceApp();
|
|
338
337
|
});
|
|
339
338
|
|
|
340
339
|
it('should be constructable', () => {
|
|
341
|
-
expect(instance).toBeInstanceOf(
|
|
340
|
+
expect(instance).toBeInstanceOf(MyBalanceApp);
|
|
342
341
|
});
|
|
343
342
|
});
|
|
344
343
|
`
|
|
345
344
|
},
|
|
346
345
|
{
|
|
347
346
|
path: "extensions/billing.customer_balance_application/index.ts",
|
|
348
|
-
content: `import type { Billing, Context } from '@stripe/extensibility-sdk
|
|
347
|
+
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
349
348
|
|
|
350
349
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
351
|
-
interface
|
|
350
|
+
interface MyBalanceAppConfig {}
|
|
352
351
|
|
|
353
|
-
export default class
|
|
352
|
+
export default class MyBalanceApp implements Billing.CustomerBalanceApplication<MyBalanceAppConfig> {
|
|
354
353
|
computeAppliedCustomerBalance(
|
|
355
354
|
request: Billing.CustomerBalanceApplication.CustomerBalanceApplicationInput,
|
|
356
|
-
_config:
|
|
355
|
+
_config: MyBalanceAppConfig,
|
|
357
356
|
_context: Context
|
|
358
357
|
) {
|
|
359
358
|
// TODO: implement your customer balance logic here
|
|
@@ -386,10 +385,10 @@ describe('MyInvoiceCollectionSetting', () => {
|
|
|
386
385
|
},
|
|
387
386
|
{
|
|
388
387
|
path: "extensions/billing.invoice_collection_setting/index.ts",
|
|
389
|
-
content: `import type { Billing, Context } from '@stripe/extensibility-sdk
|
|
388
|
+
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
390
389
|
|
|
391
390
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
392
|
-
interface MyInvoiceCollectionSettingConfig
|
|
391
|
+
interface MyInvoiceCollectionSettingConfig {}
|
|
393
392
|
|
|
394
393
|
export default class MyInvoiceCollectionSetting implements Billing.InvoiceCollectionSetting<MyInvoiceCollectionSettingConfig> {
|
|
395
394
|
collectionOverride(
|
|
@@ -425,10 +424,10 @@ describe('MyProrations', () => {
|
|
|
425
424
|
},
|
|
426
425
|
{
|
|
427
426
|
path: "extensions/billing.prorations/index.ts",
|
|
428
|
-
content: `import type { Billing, Context } from '@stripe/extensibility-sdk
|
|
427
|
+
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
429
428
|
|
|
430
429
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
431
|
-
interface MyProrationsConfig
|
|
430
|
+
interface MyProrationsConfig {}
|
|
432
431
|
|
|
433
432
|
export default class MyProrations implements Billing.Prorations<MyProrationsConfig> {
|
|
434
433
|
prorateItems(
|
|
@@ -466,10 +465,10 @@ describe('MyRecurringBillingItemHandling', () => {
|
|
|
466
465
|
},
|
|
467
466
|
{
|
|
468
467
|
path: "extensions/billing.recurring_billing_item_handling/index.ts",
|
|
469
|
-
content: `import type { Billing, Context } from '@stripe/extensibility-sdk
|
|
468
|
+
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
470
469
|
|
|
471
470
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
472
|
-
interface MyRecurringBillingItemHandlingConfig
|
|
471
|
+
interface MyRecurringBillingItemHandlingConfig {}
|
|
473
472
|
|
|
474
473
|
export default class MyRecurringBillingItemHandling implements Billing.RecurringBillingItemHandling<MyRecurringBillingItemHandlingConfig> {
|
|
475
474
|
beforeItemCreation(
|
|
@@ -716,11 +715,10 @@ describe('MyCustomAction', () => {
|
|
|
716
715
|
},
|
|
717
716
|
{
|
|
718
717
|
path: "extensions/core.workflows.custom_action/index.ts",
|
|
719
|
-
content: `import type { Core } from '@stripe/extensibility-sdk
|
|
720
|
-
import type { Context } from '@stripe/extensibility-sdk/extensions';
|
|
718
|
+
content: `import type { Core, Context } from '@stripe/extensibility-sdk';
|
|
721
719
|
|
|
722
720
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
723
|
-
interface MyCustomActionConfig
|
|
721
|
+
interface MyCustomActionConfig {}
|
|
724
722
|
|
|
725
723
|
export default class MyCustomAction implements Core.Workflows
|
|
726
724
|
.CustomAction<MyCustomActionConfig> {
|
|
@@ -780,11 +778,10 @@ describe('MyCustomAction', () => {
|
|
|
780
778
|
},
|
|
781
779
|
{
|
|
782
780
|
path: "extensions/extend.workflows.custom_action/index.ts",
|
|
783
|
-
content: `import type { Extend } from '@stripe/extensibility-sdk
|
|
784
|
-
import type { Context } from '@stripe/extensibility-sdk/extensions';
|
|
781
|
+
content: `import type { Extend, Context } from '@stripe/extensibility-sdk';
|
|
785
782
|
|
|
786
783
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
787
|
-
interface MyCustomActionConfig
|
|
784
|
+
interface MyCustomActionConfig {}
|
|
788
785
|
|
|
789
786
|
export default class MyCustomAction implements Extend.Workflows
|
|
790
787
|
.CustomAction<MyCustomActionConfig> {
|
|
@@ -871,7 +868,7 @@ generated
|
|
|
871
868
|
`
|
|
872
869
|
},
|
|
873
870
|
{
|
|
874
|
-
path: "root/custom-objects/package.json",
|
|
871
|
+
path: "root/custom-objects/package.json.mustache",
|
|
875
872
|
content: `{
|
|
876
873
|
"name": "custom-objects",
|
|
877
874
|
"type": "module",
|
|
@@ -884,12 +881,12 @@ generated
|
|
|
884
881
|
"test": "vitest run"
|
|
885
882
|
},
|
|
886
883
|
"dependencies": {
|
|
887
|
-
"@stripe/extensibility-custom-objects": "
|
|
888
|
-
"@stripe/extensibility-sdk": "
|
|
884
|
+
"@stripe/extensibility-custom-objects": "{{ customObjectsVersion }}",
|
|
885
|
+
"@stripe/extensibility-sdk": "{{ sdkVersion }}"
|
|
889
886
|
},
|
|
890
887
|
"devDependencies": {
|
|
891
|
-
"@stripe/extensibility-custom-objects-tools": "
|
|
892
|
-
"@stripe/extensibility-test-helpers": "
|
|
888
|
+
"@stripe/extensibility-custom-objects-tools": "{{ customObjectsToolsVersion }}",
|
|
889
|
+
"@stripe/extensibility-test-helpers": "{{ testHelpersVersion }}"
|
|
893
890
|
}
|
|
894
891
|
}
|
|
895
892
|
`
|
|
@@ -1246,7 +1243,7 @@ function _devNpmDep(name, version) {
|
|
|
1246
1243
|
import { _workspaceVersion } from "@stripe/extensibility-tool-utils";
|
|
1247
1244
|
var SDK_PACKAGE_NAME = "@stripe/extensibility-sdk";
|
|
1248
1245
|
var LANGUAGE_SERVER_PACKAGE_NAME = "@stripe/extensibility-language-server";
|
|
1249
|
-
var LANGUAGE_SERVER_PACKAGE_VERSION =
|
|
1246
|
+
var LANGUAGE_SERVER_PACKAGE_VERSION = `^${_workspaceVersion(LANGUAGE_SERVER_PACKAGE_NAME)}`;
|
|
1250
1247
|
function _createExtensionEslintConfigFile(params, context) {
|
|
1251
1248
|
const { id, extensionInterfaceId } = params;
|
|
1252
1249
|
const { fs: fs3 } = context;
|
|
@@ -1308,6 +1305,7 @@ function _createBaseOutput(params, context) {
|
|
|
1308
1305
|
// src/templates/extensions/core.workflows.custom_action.ts
|
|
1309
1306
|
var EXTENSION_INTERFACE_ID = "core.workflows.custom_action";
|
|
1310
1307
|
var customActionTemplate = {
|
|
1308
|
+
deprecated: true,
|
|
1311
1309
|
methods: {
|
|
1312
1310
|
execute: { implementation_types: ["script", "remote-function"] },
|
|
1313
1311
|
get_form_state: { implementation_types: ["script", "remote-function"] }
|
|
@@ -1811,7 +1809,12 @@ function toFieldSchema(schema, required) {
|
|
|
1811
1809
|
fieldSchema.valuesPresence = FieldPresence.PRESENT;
|
|
1812
1810
|
}
|
|
1813
1811
|
if (schema.default !== void 0) {
|
|
1814
|
-
|
|
1812
|
+
if (dataType === DataType.ENUM_TYPE && enumValues && (typeof schema.default !== "string" || !enumValues.includes(schema.default))) {
|
|
1813
|
+
throw new Error(
|
|
1814
|
+
`Default value ${JSON.stringify(schema.default)} is not a valid enum value. Expected one of: ${enumValues.join(", ")}`
|
|
1815
|
+
);
|
|
1816
|
+
}
|
|
1817
|
+
fieldSchema.default = toDefaultValue(schema.default, dataType);
|
|
1815
1818
|
}
|
|
1816
1819
|
return fieldSchema;
|
|
1817
1820
|
}
|
|
@@ -1874,19 +1877,22 @@ function toValueBoundary(value) {
|
|
|
1874
1877
|
`ValueBoundary only supports integers, got ${String(value)}. Custom object numeric fields are integer-only.`
|
|
1875
1878
|
);
|
|
1876
1879
|
}
|
|
1877
|
-
return {
|
|
1880
|
+
return { integerBoundary: value };
|
|
1878
1881
|
}
|
|
1879
1882
|
function toDefaultValue(value, dataType) {
|
|
1880
1883
|
if (dataType === DataType.STRING_TYPE && typeof value === "string") {
|
|
1881
|
-
return {
|
|
1884
|
+
return { stringDefault: value };
|
|
1885
|
+
}
|
|
1886
|
+
if (dataType === DataType.ENUM_TYPE && typeof value === "string") {
|
|
1887
|
+
return { stringDefault: value };
|
|
1882
1888
|
}
|
|
1883
1889
|
if (dataType === DataType.INTEGER_TYPE && typeof value === "number") {
|
|
1884
|
-
return {
|
|
1890
|
+
return { integerDefault: value };
|
|
1885
1891
|
}
|
|
1886
1892
|
if (dataType === DataType.BOOLEAN_TYPE && typeof value === "boolean") {
|
|
1887
|
-
return {
|
|
1893
|
+
return { booleanDefault: value };
|
|
1888
1894
|
}
|
|
1889
|
-
return {
|
|
1895
|
+
return {};
|
|
1890
1896
|
}
|
|
1891
1897
|
|
|
1892
1898
|
// src/custom-objects/build-definitions.ts
|
|
@@ -328,11 +328,10 @@ describe('MyDiscountCalculation', () => {
|
|
|
328
328
|
},
|
|
329
329
|
{
|
|
330
330
|
path: "extensions/billing.bill.discount_calculation/index.ts",
|
|
331
|
-
content: `import type { Billing } from '@stripe/extensibility-sdk
|
|
332
|
-
import type { Context } from '@stripe/extensibility-sdk/extensions';
|
|
331
|
+
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
333
332
|
|
|
334
333
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
335
|
-
interface MyDiscountCalculationConfig
|
|
334
|
+
interface MyDiscountCalculationConfig {}
|
|
336
335
|
|
|
337
336
|
export default class MyDiscountCalculation implements Billing.Bill
|
|
338
337
|
.DiscountCalculation<MyDiscountCalculationConfig> {
|
|
@@ -354,32 +353,32 @@ export default class MyDiscountCalculation implements Billing.Bill
|
|
|
354
353
|
path: "extensions/billing.customer_balance_application/index.test.ts",
|
|
355
354
|
content: `import { beforeEach, describe, it, expect } from 'vitest';
|
|
356
355
|
|
|
357
|
-
import
|
|
356
|
+
import MyBalanceApp from './index.js';
|
|
358
357
|
|
|
359
|
-
describe('
|
|
360
|
-
let instance:
|
|
358
|
+
describe('MyBalanceApp', () => {
|
|
359
|
+
let instance: MyBalanceApp;
|
|
361
360
|
|
|
362
361
|
beforeEach(() => {
|
|
363
|
-
instance = new
|
|
362
|
+
instance = new MyBalanceApp();
|
|
364
363
|
});
|
|
365
364
|
|
|
366
365
|
it('should be constructable', () => {
|
|
367
|
-
expect(instance).toBeInstanceOf(
|
|
366
|
+
expect(instance).toBeInstanceOf(MyBalanceApp);
|
|
368
367
|
});
|
|
369
368
|
});
|
|
370
369
|
`
|
|
371
370
|
},
|
|
372
371
|
{
|
|
373
372
|
path: "extensions/billing.customer_balance_application/index.ts",
|
|
374
|
-
content: `import type { Billing, Context } from '@stripe/extensibility-sdk
|
|
373
|
+
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
375
374
|
|
|
376
375
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
377
|
-
interface
|
|
376
|
+
interface MyBalanceAppConfig {}
|
|
378
377
|
|
|
379
|
-
export default class
|
|
378
|
+
export default class MyBalanceApp implements Billing.CustomerBalanceApplication<MyBalanceAppConfig> {
|
|
380
379
|
computeAppliedCustomerBalance(
|
|
381
380
|
request: Billing.CustomerBalanceApplication.CustomerBalanceApplicationInput,
|
|
382
|
-
_config:
|
|
381
|
+
_config: MyBalanceAppConfig,
|
|
383
382
|
_context: Context
|
|
384
383
|
) {
|
|
385
384
|
// TODO: implement your customer balance logic here
|
|
@@ -412,10 +411,10 @@ describe('MyInvoiceCollectionSetting', () => {
|
|
|
412
411
|
},
|
|
413
412
|
{
|
|
414
413
|
path: "extensions/billing.invoice_collection_setting/index.ts",
|
|
415
|
-
content: `import type { Billing, Context } from '@stripe/extensibility-sdk
|
|
414
|
+
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
416
415
|
|
|
417
416
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
418
|
-
interface MyInvoiceCollectionSettingConfig
|
|
417
|
+
interface MyInvoiceCollectionSettingConfig {}
|
|
419
418
|
|
|
420
419
|
export default class MyInvoiceCollectionSetting implements Billing.InvoiceCollectionSetting<MyInvoiceCollectionSettingConfig> {
|
|
421
420
|
collectionOverride(
|
|
@@ -451,10 +450,10 @@ describe('MyProrations', () => {
|
|
|
451
450
|
},
|
|
452
451
|
{
|
|
453
452
|
path: "extensions/billing.prorations/index.ts",
|
|
454
|
-
content: `import type { Billing, Context } from '@stripe/extensibility-sdk
|
|
453
|
+
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
455
454
|
|
|
456
455
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
457
|
-
interface MyProrationsConfig
|
|
456
|
+
interface MyProrationsConfig {}
|
|
458
457
|
|
|
459
458
|
export default class MyProrations implements Billing.Prorations<MyProrationsConfig> {
|
|
460
459
|
prorateItems(
|
|
@@ -492,10 +491,10 @@ describe('MyRecurringBillingItemHandling', () => {
|
|
|
492
491
|
},
|
|
493
492
|
{
|
|
494
493
|
path: "extensions/billing.recurring_billing_item_handling/index.ts",
|
|
495
|
-
content: `import type { Billing, Context } from '@stripe/extensibility-sdk
|
|
494
|
+
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
496
495
|
|
|
497
496
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
498
|
-
interface MyRecurringBillingItemHandlingConfig
|
|
497
|
+
interface MyRecurringBillingItemHandlingConfig {}
|
|
499
498
|
|
|
500
499
|
export default class MyRecurringBillingItemHandling implements Billing.RecurringBillingItemHandling<MyRecurringBillingItemHandlingConfig> {
|
|
501
500
|
beforeItemCreation(
|
|
@@ -742,11 +741,10 @@ describe('MyCustomAction', () => {
|
|
|
742
741
|
},
|
|
743
742
|
{
|
|
744
743
|
path: "extensions/core.workflows.custom_action/index.ts",
|
|
745
|
-
content: `import type { Core } from '@stripe/extensibility-sdk
|
|
746
|
-
import type { Context } from '@stripe/extensibility-sdk/extensions';
|
|
744
|
+
content: `import type { Core, Context } from '@stripe/extensibility-sdk';
|
|
747
745
|
|
|
748
746
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
749
|
-
interface MyCustomActionConfig
|
|
747
|
+
interface MyCustomActionConfig {}
|
|
750
748
|
|
|
751
749
|
export default class MyCustomAction implements Core.Workflows
|
|
752
750
|
.CustomAction<MyCustomActionConfig> {
|
|
@@ -806,11 +804,10 @@ describe('MyCustomAction', () => {
|
|
|
806
804
|
},
|
|
807
805
|
{
|
|
808
806
|
path: "extensions/extend.workflows.custom_action/index.ts",
|
|
809
|
-
content: `import type { Extend } from '@stripe/extensibility-sdk
|
|
810
|
-
import type { Context } from '@stripe/extensibility-sdk/extensions';
|
|
807
|
+
content: `import type { Extend, Context } from '@stripe/extensibility-sdk';
|
|
811
808
|
|
|
812
809
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
813
|
-
interface MyCustomActionConfig
|
|
810
|
+
interface MyCustomActionConfig {}
|
|
814
811
|
|
|
815
812
|
export default class MyCustomAction implements Extend.Workflows
|
|
816
813
|
.CustomAction<MyCustomActionConfig> {
|
|
@@ -897,7 +894,7 @@ generated
|
|
|
897
894
|
`
|
|
898
895
|
},
|
|
899
896
|
{
|
|
900
|
-
path: "root/custom-objects/package.json",
|
|
897
|
+
path: "root/custom-objects/package.json.mustache",
|
|
901
898
|
content: `{
|
|
902
899
|
"name": "custom-objects",
|
|
903
900
|
"type": "module",
|
|
@@ -910,12 +907,12 @@ generated
|
|
|
910
907
|
"test": "vitest run"
|
|
911
908
|
},
|
|
912
909
|
"dependencies": {
|
|
913
|
-
"@stripe/extensibility-custom-objects": "
|
|
914
|
-
"@stripe/extensibility-sdk": "
|
|
910
|
+
"@stripe/extensibility-custom-objects": "{{ customObjectsVersion }}",
|
|
911
|
+
"@stripe/extensibility-sdk": "{{ sdkVersion }}"
|
|
915
912
|
},
|
|
916
913
|
"devDependencies": {
|
|
917
|
-
"@stripe/extensibility-custom-objects-tools": "
|
|
918
|
-
"@stripe/extensibility-test-helpers": "
|
|
914
|
+
"@stripe/extensibility-custom-objects-tools": "{{ customObjectsToolsVersion }}",
|
|
915
|
+
"@stripe/extensibility-test-helpers": "{{ testHelpersVersion }}"
|
|
919
916
|
}
|
|
920
917
|
}
|
|
921
918
|
`
|
|
@@ -1272,7 +1269,7 @@ function _devNpmDep(name, version) {
|
|
|
1272
1269
|
var import_extensibility_tool_utils6 = require("@stripe/extensibility-tool-utils");
|
|
1273
1270
|
var SDK_PACKAGE_NAME = "@stripe/extensibility-sdk";
|
|
1274
1271
|
var LANGUAGE_SERVER_PACKAGE_NAME = "@stripe/extensibility-language-server";
|
|
1275
|
-
var LANGUAGE_SERVER_PACKAGE_VERSION =
|
|
1272
|
+
var LANGUAGE_SERVER_PACKAGE_VERSION = `^${(0, import_extensibility_tool_utils6._workspaceVersion)(LANGUAGE_SERVER_PACKAGE_NAME)}`;
|
|
1276
1273
|
function _createExtensionEslintConfigFile(params, context) {
|
|
1277
1274
|
const { id, extensionInterfaceId } = params;
|
|
1278
1275
|
const { fs: fs4 } = context;
|
|
@@ -1334,6 +1331,7 @@ function _createBaseOutput(params, context) {
|
|
|
1334
1331
|
// src/templates/extensions/core.workflows.custom_action.ts
|
|
1335
1332
|
var EXTENSION_INTERFACE_ID = "core.workflows.custom_action";
|
|
1336
1333
|
var customActionTemplate = {
|
|
1334
|
+
deprecated: true,
|
|
1337
1335
|
methods: {
|
|
1338
1336
|
execute: { implementation_types: ["script", "remote-function"] },
|
|
1339
1337
|
get_form_state: { implementation_types: ["script", "remote-function"] }
|
|
@@ -1837,7 +1835,12 @@ function toFieldSchema(schema, required) {
|
|
|
1837
1835
|
fieldSchema.valuesPresence = FieldPresence.PRESENT;
|
|
1838
1836
|
}
|
|
1839
1837
|
if (schema.default !== void 0) {
|
|
1840
|
-
|
|
1838
|
+
if (dataType === DataType.ENUM_TYPE && enumValues && (typeof schema.default !== "string" || !enumValues.includes(schema.default))) {
|
|
1839
|
+
throw new Error(
|
|
1840
|
+
`Default value ${JSON.stringify(schema.default)} is not a valid enum value. Expected one of: ${enumValues.join(", ")}`
|
|
1841
|
+
);
|
|
1842
|
+
}
|
|
1843
|
+
fieldSchema.default = toDefaultValue(schema.default, dataType);
|
|
1841
1844
|
}
|
|
1842
1845
|
return fieldSchema;
|
|
1843
1846
|
}
|
|
@@ -1900,19 +1903,22 @@ function toValueBoundary(value) {
|
|
|
1900
1903
|
`ValueBoundary only supports integers, got ${String(value)}. Custom object numeric fields are integer-only.`
|
|
1901
1904
|
);
|
|
1902
1905
|
}
|
|
1903
|
-
return {
|
|
1906
|
+
return { integerBoundary: value };
|
|
1904
1907
|
}
|
|
1905
1908
|
function toDefaultValue(value, dataType) {
|
|
1906
1909
|
if (dataType === DataType.STRING_TYPE && typeof value === "string") {
|
|
1907
|
-
return {
|
|
1910
|
+
return { stringDefault: value };
|
|
1911
|
+
}
|
|
1912
|
+
if (dataType === DataType.ENUM_TYPE && typeof value === "string") {
|
|
1913
|
+
return { stringDefault: value };
|
|
1908
1914
|
}
|
|
1909
1915
|
if (dataType === DataType.INTEGER_TYPE && typeof value === "number") {
|
|
1910
|
-
return {
|
|
1916
|
+
return { integerDefault: value };
|
|
1911
1917
|
}
|
|
1912
1918
|
if (dataType === DataType.BOOLEAN_TYPE && typeof value === "boolean") {
|
|
1913
|
-
return {
|
|
1919
|
+
return { booleanDefault: value };
|
|
1914
1920
|
}
|
|
1915
|
-
return {
|
|
1921
|
+
return {};
|
|
1916
1922
|
}
|
|
1917
1923
|
|
|
1918
1924
|
// src/custom-objects/build-definitions.ts
|