@stripe/extensibility-dev-tools 0.24.2 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/build-custom-object-definitions.cjs +203 -46
- package/dist/bin/build-custom-object-definitions.js +194 -37
- package/dist/bin/create-upload-image.cjs +206 -46
- package/dist/bin/create-upload-image.js +201 -41
- package/dist/bin/dev-tools-rpc.cjs +199 -59
- package/dist/bin/dev-tools-rpc.js +174 -34
- package/dist/bin/gen-workspace.cjs +187 -47
- package/dist/bin/gen-workspace.js +174 -34
- package/dist/bin/template-info.cjs +161 -30
- package/dist/bin/template-info.js +156 -25
- package/dist/custom-objects/build-definitions.d.ts.map +1 -1
- package/dist/custom-objects/generated/proto/custom_objects/pub/api/app_api/object_definitions_app_service.pb.d.ts +32 -0
- package/dist/custom-objects/generated/proto/custom_objects/pub/api/app_api/object_definitions_app_service.pb.d.ts.map +1 -1
- package/dist/custom-objects/generated/proto/google/protobuf/descriptor.pb.d.ts +2 -2
- package/dist/custom-objects/generated/proto/google/protobuf/wrappers.pb.d.ts +168 -0
- package/dist/custom-objects/generated/proto/google/protobuf/wrappers.pb.d.ts.map +1 -0
- package/dist/custom-objects/generated/proto/proto/extensions.pb.d.ts +4 -4
- package/dist/custom-objects/generated/proto/proto/extensions.pb.d.ts.map +1 -1
- package/dist/custom-objects/generated/proto/vendor/proto/model/common/common_model.pb.d.ts +1553 -0
- package/dist/custom-objects/generated/proto/vendor/proto/model/common/common_model.pb.d.ts.map +1 -0
- package/dist/custom-objects/generated/proto/vendor/proto/model/common/kronos_model.pb.d.ts +1372 -0
- package/dist/custom-objects/generated/proto/vendor/proto/model/common/kronos_model.pb.d.ts.map +1 -0
- package/dist/custom-objects/generated/proto/vendor/publicapi/api_group_enum.pb.d.ts +2 -0
- package/dist/custom-objects/generated/proto/vendor/publicapi/api_group_enum.pb.d.ts.map +1 -1
- package/dist/custom-objects/generated/proto/vendor/publicapi/extension_interface.pb.d.ts +2 -0
- package/dist/custom-objects/generated/proto/vendor/publicapi/extension_interface.pb.d.ts.map +1 -1
- package/dist/custom-objects/generated/proto/vendor/publicapi/feature_enum.pb.d.ts +14 -2
- package/dist/custom-objects/generated/proto/vendor/publicapi/feature_enum.pb.d.ts.map +1 -1
- package/dist/custom-objects/generated/proto/vendor/publicapi/http_error_status.pb.d.ts +6 -0
- package/dist/custom-objects/generated/proto/vendor/publicapi/http_error_status.pb.d.ts.map +1 -1
- package/dist/custom-objects/generated/proto/vendor/publicapi/rollout_configs.pb.d.ts +74 -0
- package/dist/custom-objects/generated/proto/vendor/publicapi/rollout_configs.pb.d.ts.map +1 -1
- package/dist/custom-objects/generated/proto/vendor/publicapi/v2ext.pb.d.ts +10 -3
- package/dist/custom-objects/generated/proto/vendor/publicapi/v2ext.pb.d.ts.map +1 -1
- package/dist/custom-objects/generated/proto/vendor/vext/privacy_unified_annotations.pb.d.ts +1 -0
- package/dist/custom-objects/generated/proto/vendor/vext/privacy_unified_annotations.pb.d.ts.map +1 -1
- package/dist/index.cjs +192 -52
- package/dist/index.js +174 -34
- package/dist/templates/extensions/billing.invoice_collection_options.d.ts +6 -0
- package/dist/templates/extensions/billing.invoice_collection_options.d.ts.map +1 -0
- package/dist/templates/index.cjs +174 -34
- package/dist/templates/index.js +172 -32
- package/dist/templates/root/index.d.ts.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/workspace/index.cjs +183 -43
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +174 -34
- package/dist/workspace-versions.d.ts +26 -0
- package/dist/workspace-versions.d.ts.map +1 -0
- package/package.json +4 -4
- package/templates/extensions/billing.invoice_collection_options/index.test.ts +15 -0
- package/templates/extensions/billing.invoice_collection_options/index.ts +16 -0
- package/templates/root/custom-objects/eslint.config.mts +89 -0
- package/templates/root/custom-objects/package.json.mustache +2 -0
- package/templates/root/custom-objects/tsconfig.json +1 -0
- package/templates/root/custom-objects/vitest.config.mts +7 -0
- package/templates/root/package.json.mustache +1 -1
- package/templates/root/tools/test.mts +4 -2
- package/dist/templates/extensions/billing.invoice_collection_setting.d.ts +0 -6
- package/dist/templates/extensions/billing.invoice_collection_setting.d.ts.map +0 -1
- package/templates/extensions/billing.invoice_collection_setting/index.test.ts +0 -15
- package/templates/extensions/billing.invoice_collection_setting/index.ts +0 -16
|
@@ -24,7 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
));
|
|
25
25
|
|
|
26
26
|
// src/bin/build-custom-object-definitions.ts
|
|
27
|
-
var
|
|
27
|
+
var import_extensibility_tool_utils7 = require("@stripe/extensibility-tool-utils");
|
|
28
28
|
|
|
29
29
|
// src/custom-objects/build-definitions.ts
|
|
30
30
|
var fs2 = __toESM(require("fs"), 1);
|
|
@@ -388,35 +388,35 @@ export default class MyBalanceApp implements Billing.CustomerBalanceApplication<
|
|
|
388
388
|
`
|
|
389
389
|
},
|
|
390
390
|
{
|
|
391
|
-
path: "extensions/billing.
|
|
391
|
+
path: "extensions/billing.invoice_collection_options/index.test.ts",
|
|
392
392
|
content: `import { beforeEach, describe, it, expect } from 'vitest';
|
|
393
393
|
|
|
394
|
-
import
|
|
394
|
+
import MyInvoiceCollectionOptions from './index.js';
|
|
395
395
|
|
|
396
|
-
describe('
|
|
397
|
-
let instance:
|
|
396
|
+
describe('MyInvoiceCollectionOptions', () => {
|
|
397
|
+
let instance: MyInvoiceCollectionOptions;
|
|
398
398
|
|
|
399
399
|
beforeEach(() => {
|
|
400
|
-
instance = new
|
|
400
|
+
instance = new MyInvoiceCollectionOptions();
|
|
401
401
|
});
|
|
402
402
|
|
|
403
403
|
it('should be constructable', () => {
|
|
404
|
-
expect(instance).toBeInstanceOf(
|
|
404
|
+
expect(instance).toBeInstanceOf(MyInvoiceCollectionOptions);
|
|
405
405
|
});
|
|
406
406
|
});
|
|
407
407
|
`
|
|
408
408
|
},
|
|
409
409
|
{
|
|
410
|
-
path: "extensions/billing.
|
|
410
|
+
path: "extensions/billing.invoice_collection_options/index.ts",
|
|
411
411
|
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
412
412
|
|
|
413
413
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
414
|
-
interface
|
|
414
|
+
interface MyInvoiceCollectionOptionsConfig {}
|
|
415
415
|
|
|
416
|
-
export default class
|
|
417
|
-
|
|
418
|
-
_request: Billing.
|
|
419
|
-
_config:
|
|
416
|
+
export default class MyInvoiceCollectionOptions implements Billing.InvoiceCollectionOptions<MyInvoiceCollectionOptionsConfig> {
|
|
417
|
+
overrideOptions(
|
|
418
|
+
_request: Billing.InvoiceCollectionOptions.InvoiceCollectionOptionsInput,
|
|
419
|
+
_config: MyInvoiceCollectionOptionsConfig,
|
|
420
420
|
_context: Context
|
|
421
421
|
) {
|
|
422
422
|
// TODO: implement your collection setting logic here
|
|
@@ -888,6 +888,99 @@ install-deps.log
|
|
|
888
888
|
|
|
889
889
|
# generated schemas
|
|
890
890
|
generated
|
|
891
|
+
`
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
path: "root/custom-objects/eslint.config.mts",
|
|
895
|
+
content: `import eslint from '@eslint/js';
|
|
896
|
+
import { defineConfig } from 'eslint/config';
|
|
897
|
+
import tseslint from 'typescript-eslint';
|
|
898
|
+
import eslintConfigPrettier from 'eslint-config-prettier/flat';
|
|
899
|
+
|
|
900
|
+
import globals from 'globals';
|
|
901
|
+
|
|
902
|
+
import stripeAppsConfig from '@stripe/extensibility-eslint-plugin';
|
|
903
|
+
import customObjectsConfig from '@stripe/extensibility-eslint-plugin/custom-objects';
|
|
904
|
+
|
|
905
|
+
export default defineConfig([
|
|
906
|
+
eslint.configs.recommended,
|
|
907
|
+
...tseslint.configs.recommended,
|
|
908
|
+
...stripeAppsConfig,
|
|
909
|
+
...customObjectsConfig,
|
|
910
|
+
|
|
911
|
+
// Global ignores
|
|
912
|
+
{
|
|
913
|
+
ignores: ['dist', 'generated', 'node_modules'],
|
|
914
|
+
},
|
|
915
|
+
|
|
916
|
+
// TypeScript source files (with type-checking)
|
|
917
|
+
{
|
|
918
|
+
name: 'sources',
|
|
919
|
+
files: ['src/**/*.ts'],
|
|
920
|
+
ignores: ['**/*.test.ts', '**/__tests__/**'],
|
|
921
|
+
languageOptions: {
|
|
922
|
+
globals: {
|
|
923
|
+
...globals.node,
|
|
924
|
+
},
|
|
925
|
+
parserOptions: {
|
|
926
|
+
projectService: true,
|
|
927
|
+
tsconfigRootDir: import.meta.dirname,
|
|
928
|
+
},
|
|
929
|
+
},
|
|
930
|
+
},
|
|
931
|
+
|
|
932
|
+
// Test files
|
|
933
|
+
{
|
|
934
|
+
name: 'tests',
|
|
935
|
+
files: ['src/**/*.test.ts', 'src/**/__tests__/**/*.ts'],
|
|
936
|
+
languageOptions: {
|
|
937
|
+
globals: {
|
|
938
|
+
...globals.node,
|
|
939
|
+
},
|
|
940
|
+
parserOptions: {
|
|
941
|
+
projectService: true,
|
|
942
|
+
tsconfigRootDir: import.meta.dirname,
|
|
943
|
+
},
|
|
944
|
+
},
|
|
945
|
+
},
|
|
946
|
+
|
|
947
|
+
// Config files
|
|
948
|
+
{
|
|
949
|
+
name: 'ts-configs',
|
|
950
|
+
files: ['*.config.m?ts', 'eslint.config.mts'],
|
|
951
|
+
languageOptions: {
|
|
952
|
+
globals: {
|
|
953
|
+
...globals.node,
|
|
954
|
+
},
|
|
955
|
+
parserOptions: {
|
|
956
|
+
projectService: false,
|
|
957
|
+
},
|
|
958
|
+
},
|
|
959
|
+
rules: {
|
|
960
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
961
|
+
},
|
|
962
|
+
},
|
|
963
|
+
|
|
964
|
+
// JavaScript/MJS files (scripts, configs) \u2014 no TS project, so only
|
|
965
|
+
// disable the TS-parser-specific rule that doesn't apply without it.
|
|
966
|
+
{
|
|
967
|
+
name: 'js-configs',
|
|
968
|
+
files: ['**/*.js', '**/*.mjs'],
|
|
969
|
+
languageOptions: {
|
|
970
|
+
globals: {
|
|
971
|
+
...globals.node,
|
|
972
|
+
},
|
|
973
|
+
parserOptions: {
|
|
974
|
+
projectService: false,
|
|
975
|
+
},
|
|
976
|
+
},
|
|
977
|
+
rules: {
|
|
978
|
+
'@typescript-eslint/no-require-imports': 'off',
|
|
979
|
+
},
|
|
980
|
+
},
|
|
981
|
+
|
|
982
|
+
eslintConfigPrettier,
|
|
983
|
+
]);
|
|
891
984
|
`
|
|
892
985
|
},
|
|
893
986
|
{
|
|
@@ -900,7 +993,9 @@ generated
|
|
|
900
993
|
"private": true,
|
|
901
994
|
"scripts": {
|
|
902
995
|
"build": "test -d src && custom-objects-build --input src --output dist || true",
|
|
996
|
+
"lint": "pnpm lint:types && pnpm lint:eslint",
|
|
903
997
|
"lint:types": "test ! -d src || tsc --noEmit",
|
|
998
|
+
"lint:eslint": "eslint .",
|
|
904
999
|
"test": "vitest run"
|
|
905
1000
|
},
|
|
906
1001
|
"dependencies": {
|
|
@@ -923,8 +1018,20 @@ generated
|
|
|
923
1018
|
"moduleResolution": "bundler",
|
|
924
1019
|
"types": ["vitest/globals"]
|
|
925
1020
|
},
|
|
1021
|
+
"include": ["src/**/*.ts"],
|
|
926
1022
|
"exclude": ["dist"]
|
|
927
1023
|
}
|
|
1024
|
+
`
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
path: "root/custom-objects/vitest.config.mts",
|
|
1028
|
+
content: `import { defineConfig } from 'vitest/config';
|
|
1029
|
+
|
|
1030
|
+
export default defineConfig({
|
|
1031
|
+
test: {
|
|
1032
|
+
globals: true,
|
|
1033
|
+
},
|
|
1034
|
+
});
|
|
928
1035
|
`
|
|
929
1036
|
},
|
|
930
1037
|
{
|
|
@@ -1042,7 +1149,7 @@ export default defineConfig([
|
|
|
1042
1149
|
"build": "pnpm -r --if-present build",
|
|
1043
1150
|
"lint": "pnpm lint:types && pnpm lint:eslint && pnpm lint:format",
|
|
1044
1151
|
"lint:types": "pnpm -r --if-present lint:types",
|
|
1045
|
-
"lint:eslint": "eslint . --ignore-pattern 'extensions/**' && pnpm -r --filter './extensions/*' --if-present lint:eslint",
|
|
1152
|
+
"lint:eslint": "eslint . --ignore-pattern 'extensions/**' && pnpm -r --filter './extensions/*' --if-present lint:eslint && pnpm -r --filter './custom-objects' --if-present lint:eslint",
|
|
1046
1153
|
"lint:format": "prettier --check .",
|
|
1047
1154
|
"fix:lint": "eslint --fix . --ignore-pattern 'extensions/**' && pnpm -r --filter './extensions/*' --if-present fix:lint",
|
|
1048
1155
|
"fix:format": "prettier --write .",
|
|
@@ -1088,7 +1195,7 @@ declarations:
|
|
|
1088
1195
|
content: `#!/usr/bin/env tsx
|
|
1089
1196
|
/**
|
|
1090
1197
|
* Runs tests across the workspace:
|
|
1091
|
-
* - vitest for script extensions and custom objects (
|
|
1198
|
+
* - vitest for script extensions (extensions/*) and custom objects (custom-objects/)
|
|
1092
1199
|
* - jest for UI extensions (ui/)
|
|
1093
1200
|
*/
|
|
1094
1201
|
import { existsSync, readdirSync } from 'node:fs';
|
|
@@ -1098,6 +1205,8 @@ const hasExtensions =
|
|
|
1098
1205
|
existsSync('extensions') &&
|
|
1099
1206
|
readdirSync('extensions').some((name) => existsSync(\`extensions/\${name}/package.json\`));
|
|
1100
1207
|
|
|
1208
|
+
const hasCustomObjects = existsSync('custom-objects/package.json');
|
|
1209
|
+
|
|
1101
1210
|
const hasUI = existsSync('ui/package.json');
|
|
1102
1211
|
|
|
1103
1212
|
let exitCode = 0;
|
|
@@ -1110,7 +1219,7 @@ function run(cmd: string): void {
|
|
|
1110
1219
|
}
|
|
1111
1220
|
}
|
|
1112
1221
|
|
|
1113
|
-
if (hasExtensions) {
|
|
1222
|
+
if (hasExtensions || hasCustomObjects) {
|
|
1114
1223
|
run('vitest run');
|
|
1115
1224
|
}
|
|
1116
1225
|
|
|
@@ -1262,11 +1371,33 @@ function _devNpmDep(name, version) {
|
|
|
1262
1371
|
return { type: "dev-npm", name, version };
|
|
1263
1372
|
}
|
|
1264
1373
|
|
|
1374
|
+
// src/workspace-versions.json
|
|
1375
|
+
var workspace_versions_default = {
|
|
1376
|
+
"@stripe/extensibility-custom-objects": "0.8.0",
|
|
1377
|
+
"@stripe/extensibility-custom-objects-tools": "0.42.1",
|
|
1378
|
+
"@stripe/extensibility-dev-tools": "0.25.1",
|
|
1379
|
+
"@stripe/extensibility-eslint-plugin": "0.17.1",
|
|
1380
|
+
"@stripe/extensibility-language-server": "0.3.4",
|
|
1381
|
+
"@stripe/extensibility-sdk": "0.27.1",
|
|
1382
|
+
"@stripe/extensibility-test-helpers": "0.2.7"
|
|
1383
|
+
};
|
|
1384
|
+
|
|
1385
|
+
// src/workspace-versions.ts
|
|
1386
|
+
var _workspaceVersions = workspace_versions_default;
|
|
1387
|
+
function _workspaceVersion(packageName) {
|
|
1388
|
+
const v = _workspaceVersions[packageName];
|
|
1389
|
+
if (v === void 0) {
|
|
1390
|
+
throw new Error(
|
|
1391
|
+
`Unknown workspace package "${packageName}". Check workspace-versions.json or run: tsx scripts/src/sync-workspace-versions.ts`
|
|
1392
|
+
);
|
|
1393
|
+
}
|
|
1394
|
+
return v;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1265
1397
|
// src/templates/extensions/base.ts
|
|
1266
|
-
var import_extensibility_tool_utils6 = require("@stripe/extensibility-tool-utils");
|
|
1267
1398
|
var SDK_PACKAGE_NAME = "@stripe/extensibility-sdk";
|
|
1268
1399
|
var LANGUAGE_SERVER_PACKAGE_NAME = "@stripe/extensibility-language-server";
|
|
1269
|
-
var LANGUAGE_SERVER_PACKAGE_VERSION = `^${
|
|
1400
|
+
var LANGUAGE_SERVER_PACKAGE_VERSION = `^${_workspaceVersion(LANGUAGE_SERVER_PACKAGE_NAME)}`;
|
|
1270
1401
|
function _createExtensionEslintConfigFile(params, context) {
|
|
1271
1402
|
const { id, extensionInterfaceId } = params;
|
|
1272
1403
|
const { fs: fs3 } = context;
|
|
@@ -1309,7 +1440,7 @@ function _createBaseOutput(params, context) {
|
|
|
1309
1440
|
dependencies: {
|
|
1310
1441
|
// Exact pin (no caret) — the SDK is tightly coupled to dev-tools and
|
|
1311
1442
|
// must match the version that generated the extension scaffolding.
|
|
1312
|
-
runtime: [_npmDep(SDK_PACKAGE_NAME,
|
|
1443
|
+
runtime: [_npmDep(SDK_PACKAGE_NAME, _workspaceVersion(SDK_PACKAGE_NAME))],
|
|
1313
1444
|
dev: [_devNpmDep(LANGUAGE_SERVER_PACKAGE_NAME, LANGUAGE_SERVER_PACKAGE_VERSION)]
|
|
1314
1445
|
},
|
|
1315
1446
|
postGenerationHooks: [
|
|
@@ -1568,14 +1699,14 @@ var billing_bill_discount_calculation_default = {
|
|
|
1568
1699
|
[EXTENSION_INTERFACE_ID5]: discountCalculationTemplate
|
|
1569
1700
|
};
|
|
1570
1701
|
|
|
1571
|
-
// src/templates/extensions/billing.
|
|
1572
|
-
var EXTENSION_INTERFACE_ID6 = "billing.
|
|
1573
|
-
var
|
|
1702
|
+
// src/templates/extensions/billing.invoice_collection_options.ts
|
|
1703
|
+
var EXTENSION_INTERFACE_ID6 = "billing.invoice_collection_options";
|
|
1704
|
+
var invoiceCollectionOptionsTemplate = {
|
|
1574
1705
|
hidden: true,
|
|
1575
1706
|
methods: {
|
|
1576
|
-
|
|
1707
|
+
override_options: { implementation_types: ["script"] }
|
|
1577
1708
|
},
|
|
1578
|
-
description: "Use Stripe Scripts to create custom invoice collection
|
|
1709
|
+
description: "Use Stripe Scripts to create custom invoice collection options that controls how your integration handles invoices generated from subscriptions.",
|
|
1579
1710
|
generate: (params, context) => {
|
|
1580
1711
|
const { id } = params;
|
|
1581
1712
|
const { fs: fs3 } = context;
|
|
@@ -1603,15 +1734,15 @@ var invoiceCollectionSettingTemplate = {
|
|
|
1603
1734
|
...base.files
|
|
1604
1735
|
],
|
|
1605
1736
|
methods: {
|
|
1606
|
-
|
|
1737
|
+
override_options: {
|
|
1607
1738
|
implementation_type: "script"
|
|
1608
1739
|
}
|
|
1609
1740
|
}
|
|
1610
1741
|
};
|
|
1611
1742
|
}
|
|
1612
1743
|
};
|
|
1613
|
-
var
|
|
1614
|
-
[EXTENSION_INTERFACE_ID6]:
|
|
1744
|
+
var billing_invoice_collection_options_default = {
|
|
1745
|
+
[EXTENSION_INTERFACE_ID6]: invoiceCollectionOptionsTemplate
|
|
1615
1746
|
};
|
|
1616
1747
|
|
|
1617
1748
|
// src/templates/extensions/billing.prorations.ts
|
|
@@ -1719,7 +1850,7 @@ var DEFAULT_TEMPLATES = {
|
|
|
1719
1850
|
...extend_workflows_custom_action_default,
|
|
1720
1851
|
...billing_customer_balance_application_default,
|
|
1721
1852
|
...billing_bill_discount_calculation_default,
|
|
1722
|
-
...
|
|
1853
|
+
...billing_invoice_collection_options_default,
|
|
1723
1854
|
...billing_prorations_default,
|
|
1724
1855
|
...billing_recurring_billing_item_handling_default
|
|
1725
1856
|
};
|
|
@@ -1785,10 +1916,11 @@ function mapActions(actions) {
|
|
|
1785
1916
|
}
|
|
1786
1917
|
function mapProperties(schema) {
|
|
1787
1918
|
const result = {};
|
|
1788
|
-
const
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1919
|
+
const resolvedSchema = schema === null || schema === void 0 ? schema : resolveRef(schema, schema.$defs ?? {});
|
|
1920
|
+
const requiredSet = new Set(resolvedSchema?.required ?? []);
|
|
1921
|
+
if (!resolvedSchema?.properties) return result;
|
|
1922
|
+
const defs = resolvedSchema.$defs ?? {};
|
|
1923
|
+
for (const [key, propSchema] of Object.entries(resolvedSchema.properties)) {
|
|
1792
1924
|
result[key] = toFieldSchema(resolveRef(propSchema, defs), requiredSet.has(key));
|
|
1793
1925
|
}
|
|
1794
1926
|
return result;
|
|
@@ -1832,10 +1964,11 @@ function toFieldSchema(schema, required) {
|
|
|
1832
1964
|
fieldSchema.valuesPresence = FieldPresence.PRESENT;
|
|
1833
1965
|
}
|
|
1834
1966
|
if (schema.default !== void 0) {
|
|
1835
|
-
if (dataType === DataType.ENUM_TYPE && enumValues
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1967
|
+
if (dataType === DataType.ENUM_TYPE && enumValues) {
|
|
1968
|
+
validateEnumDefault(schema.default, enumValues);
|
|
1969
|
+
}
|
|
1970
|
+
if (dataType === DataType.DATETIME_TYPE) {
|
|
1971
|
+
validateDatetimeDefault(schema.default);
|
|
1839
1972
|
}
|
|
1840
1973
|
fieldSchema.default = toDefaultValue(schema.default, dataType);
|
|
1841
1974
|
}
|
|
@@ -1849,7 +1982,6 @@ function resolveDataType(schema, enumValues, refTarget) {
|
|
|
1849
1982
|
if (schema.format === "date-time") return DataType.DATETIME_TYPE;
|
|
1850
1983
|
return DataType.STRING_TYPE;
|
|
1851
1984
|
case "integer":
|
|
1852
|
-
case "number":
|
|
1853
1985
|
return DataType.INTEGER_TYPE;
|
|
1854
1986
|
case "boolean":
|
|
1855
1987
|
return DataType.BOOLEAN_TYPE;
|
|
@@ -1886,14 +2018,31 @@ function extractSingleLiteral(schema) {
|
|
|
1886
2018
|
return null;
|
|
1887
2019
|
}
|
|
1888
2020
|
function extractEnumValues(schema) {
|
|
1889
|
-
if (schema.enum) {
|
|
2021
|
+
if (Array.isArray(schema.enum) && schema.enum.every((value) => typeof value === "string")) {
|
|
1890
2022
|
return schema.enum.map(String);
|
|
1891
2023
|
}
|
|
1892
|
-
if (Array.isArray(schema.oneOf) && schema.oneOf.length > 0 && schema.oneOf.every(
|
|
2024
|
+
if (Array.isArray(schema.oneOf) && schema.oneOf.length > 0 && schema.oneOf.every(
|
|
2025
|
+
(item) => "const" in item && typeof item.const === "string"
|
|
2026
|
+
)) {
|
|
1893
2027
|
return schema.oneOf.map((item) => String(item.const));
|
|
1894
2028
|
}
|
|
1895
2029
|
return null;
|
|
1896
2030
|
}
|
|
2031
|
+
function validateEnumDefault(value, enumValues) {
|
|
2032
|
+
if (typeof value !== "string" || !enumValues.includes(value)) {
|
|
2033
|
+
throw new Error(
|
|
2034
|
+
`Default value ${JSON.stringify(value)} is not a valid enum value. Expected one of: ${enumValues.join(", ")}`
|
|
2035
|
+
);
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
var DATETIME_UTC_MS_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}(Z|\+00:00)$/;
|
|
2039
|
+
function validateDatetimeDefault(value) {
|
|
2040
|
+
if (typeof value !== "string" || !DATETIME_UTC_MS_RE.test(value)) {
|
|
2041
|
+
throw new Error(
|
|
2042
|
+
`Default value ${JSON.stringify(value)} is not a valid ISO 8601 UTC datetime with millisecond precision. Expected format: YYYY-MM-DDTHH:mm:ss.sssZ or YYYY-MM-DDTHH:mm:ss.sss+00:00`
|
|
2043
|
+
);
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
1897
2046
|
function toValueBoundary(value) {
|
|
1898
2047
|
if (!Number.isInteger(value)) {
|
|
1899
2048
|
throw new Error(
|
|
@@ -1909,7 +2058,15 @@ function toDefaultValue(value, dataType) {
|
|
|
1909
2058
|
if (dataType === DataType.ENUM_TYPE && typeof value === "string") {
|
|
1910
2059
|
return { stringDefault: value };
|
|
1911
2060
|
}
|
|
2061
|
+
if (dataType === DataType.DATETIME_TYPE && typeof value === "string") {
|
|
2062
|
+
return { stringDefault: value };
|
|
2063
|
+
}
|
|
1912
2064
|
if (dataType === DataType.INTEGER_TYPE && typeof value === "number") {
|
|
2065
|
+
if (!Number.isInteger(value)) {
|
|
2066
|
+
throw new Error(
|
|
2067
|
+
`Integer default values must be whole numbers, got ${JSON.stringify(value)}.`
|
|
2068
|
+
);
|
|
2069
|
+
}
|
|
1913
2070
|
return { integerDefault: value };
|
|
1914
2071
|
}
|
|
1915
2072
|
if (dataType === DataType.BOOLEAN_TYPE && typeof value === "boolean") {
|
|
@@ -1919,9 +2076,9 @@ function toDefaultValue(value, dataType) {
|
|
|
1919
2076
|
}
|
|
1920
2077
|
|
|
1921
2078
|
// src/custom-objects/build-definitions.ts
|
|
1922
|
-
var
|
|
2079
|
+
var import_extensibility_tool_utils6 = require("@stripe/extensibility-tool-utils");
|
|
1923
2080
|
async function analyzeAndInjectManifest(options) {
|
|
1924
|
-
const context = options.context ?? (0,
|
|
2081
|
+
const context = options.context ?? (0, import_extensibility_tool_utils6._createCliContext)();
|
|
1925
2082
|
const manifestPath = options.manifestPath ?? "stripe-app.yaml";
|
|
1926
2083
|
const projectRoot = options.projectRoot ?? path2.dirname(path2.resolve(manifestPath));
|
|
1927
2084
|
const resolvedManifestPath = path2.resolve(manifestPath);
|
|
@@ -1945,7 +2102,7 @@ async function analyzeAndInjectManifest(options) {
|
|
|
1945
2102
|
(diagnostic) => diagnostic.severity === "error"
|
|
1946
2103
|
);
|
|
1947
2104
|
if (errorDiagnostics.length > 0) {
|
|
1948
|
-
const details = errorDiagnostics.map((diagnostic) => diagnostic.message).join("
|
|
2105
|
+
const details = errorDiagnostics.map((diagnostic) => diagnostic.message).join("\n");
|
|
1949
2106
|
throw new Error(details);
|
|
1950
2107
|
}
|
|
1951
2108
|
const coPackageJsonPath = path2.join(projectRoot, "custom-objects", "package.json");
|
|
@@ -2006,7 +2163,7 @@ async function analyzeAndInjectManifest(options) {
|
|
|
2006
2163
|
};
|
|
2007
2164
|
}
|
|
2008
2165
|
async function writeCustomObjectArtifacts(options, state) {
|
|
2009
|
-
const context = options.context ?? (0,
|
|
2166
|
+
const context = options.context ?? (0, import_extensibility_tool_utils6._createCliContext)();
|
|
2010
2167
|
const targetPath = path2.resolve(options.targetPath);
|
|
2011
2168
|
const { packageBuild, customObjects, coVersion, coDependencies, projectRoot } = state;
|
|
2012
2169
|
for (const obj of customObjects) {
|
|
@@ -2096,10 +2253,10 @@ function readPackageDependencies(packageJsonPath) {
|
|
|
2096
2253
|
}
|
|
2097
2254
|
|
|
2098
2255
|
// src/bin/build-custom-object-definitions.ts
|
|
2099
|
-
var
|
|
2100
|
-
var logger = (0,
|
|
2256
|
+
var import_extensibility_tool_utils8 = require("@stripe/extensibility-tool-utils");
|
|
2257
|
+
var logger = (0, import_extensibility_tool_utils7._createLogger)({ name: "build-definitions" });
|
|
2101
2258
|
async function main() {
|
|
2102
|
-
const ctx = (0,
|
|
2259
|
+
const ctx = (0, import_extensibility_tool_utils8._createCliContext)();
|
|
2103
2260
|
const [targetPath, manifestPath] = process.argv.slice(2);
|
|
2104
2261
|
if (!targetPath) {
|
|
2105
2262
|
ctx.ux.error("Usage: build-custom-object-definitions <target-path> [manifest-path]");
|