@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
|
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
// src/bin/gen-workspace.ts
|
|
27
27
|
var import_yargs = __toESM(require("yargs"), 1);
|
|
28
28
|
var import_helpers = require("yargs/helpers");
|
|
29
|
-
var
|
|
29
|
+
var import_extensibility_tool_utils10 = require("@stripe/extensibility-tool-utils");
|
|
30
30
|
|
|
31
31
|
// src/workspace/index.ts
|
|
32
32
|
var import_zod = require("zod");
|
|
@@ -586,7 +586,7 @@ var _DependencyManager = class {
|
|
|
586
586
|
|
|
587
587
|
// src/workspace/index.ts
|
|
588
588
|
var import_internal = require("@stripe/extensibility-custom-objects-tools/internal");
|
|
589
|
-
var
|
|
589
|
+
var import_extensibility_tool_utils9 = require("@stripe/extensibility-tool-utils");
|
|
590
590
|
|
|
591
591
|
// src/manifest/stripe-app-manifest.ts
|
|
592
592
|
var import_extensibility_tool_utils3 = require("@stripe/extensibility-tool-utils");
|
|
@@ -1247,35 +1247,35 @@ export default class MyBalanceApp implements Billing.CustomerBalanceApplication<
|
|
|
1247
1247
|
`
|
|
1248
1248
|
},
|
|
1249
1249
|
{
|
|
1250
|
-
path: "extensions/billing.
|
|
1250
|
+
path: "extensions/billing.invoice_collection_options/index.test.ts",
|
|
1251
1251
|
content: `import { beforeEach, describe, it, expect } from 'vitest';
|
|
1252
1252
|
|
|
1253
|
-
import
|
|
1253
|
+
import MyInvoiceCollectionOptions from './index.js';
|
|
1254
1254
|
|
|
1255
|
-
describe('
|
|
1256
|
-
let instance:
|
|
1255
|
+
describe('MyInvoiceCollectionOptions', () => {
|
|
1256
|
+
let instance: MyInvoiceCollectionOptions;
|
|
1257
1257
|
|
|
1258
1258
|
beforeEach(() => {
|
|
1259
|
-
instance = new
|
|
1259
|
+
instance = new MyInvoiceCollectionOptions();
|
|
1260
1260
|
});
|
|
1261
1261
|
|
|
1262
1262
|
it('should be constructable', () => {
|
|
1263
|
-
expect(instance).toBeInstanceOf(
|
|
1263
|
+
expect(instance).toBeInstanceOf(MyInvoiceCollectionOptions);
|
|
1264
1264
|
});
|
|
1265
1265
|
});
|
|
1266
1266
|
`
|
|
1267
1267
|
},
|
|
1268
1268
|
{
|
|
1269
|
-
path: "extensions/billing.
|
|
1269
|
+
path: "extensions/billing.invoice_collection_options/index.ts",
|
|
1270
1270
|
content: `import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
1271
1271
|
|
|
1272
1272
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
1273
|
-
interface
|
|
1273
|
+
interface MyInvoiceCollectionOptionsConfig {}
|
|
1274
1274
|
|
|
1275
|
-
export default class
|
|
1276
|
-
|
|
1277
|
-
_request: Billing.
|
|
1278
|
-
_config:
|
|
1275
|
+
export default class MyInvoiceCollectionOptions implements Billing.InvoiceCollectionOptions<MyInvoiceCollectionOptionsConfig> {
|
|
1276
|
+
overrideOptions(
|
|
1277
|
+
_request: Billing.InvoiceCollectionOptions.InvoiceCollectionOptionsInput,
|
|
1278
|
+
_config: MyInvoiceCollectionOptionsConfig,
|
|
1279
1279
|
_context: Context
|
|
1280
1280
|
) {
|
|
1281
1281
|
// TODO: implement your collection setting logic here
|
|
@@ -1747,6 +1747,99 @@ install-deps.log
|
|
|
1747
1747
|
|
|
1748
1748
|
# generated schemas
|
|
1749
1749
|
generated
|
|
1750
|
+
`
|
|
1751
|
+
},
|
|
1752
|
+
{
|
|
1753
|
+
path: "root/custom-objects/eslint.config.mts",
|
|
1754
|
+
content: `import eslint from '@eslint/js';
|
|
1755
|
+
import { defineConfig } from 'eslint/config';
|
|
1756
|
+
import tseslint from 'typescript-eslint';
|
|
1757
|
+
import eslintConfigPrettier from 'eslint-config-prettier/flat';
|
|
1758
|
+
|
|
1759
|
+
import globals from 'globals';
|
|
1760
|
+
|
|
1761
|
+
import stripeAppsConfig from '@stripe/extensibility-eslint-plugin';
|
|
1762
|
+
import customObjectsConfig from '@stripe/extensibility-eslint-plugin/custom-objects';
|
|
1763
|
+
|
|
1764
|
+
export default defineConfig([
|
|
1765
|
+
eslint.configs.recommended,
|
|
1766
|
+
...tseslint.configs.recommended,
|
|
1767
|
+
...stripeAppsConfig,
|
|
1768
|
+
...customObjectsConfig,
|
|
1769
|
+
|
|
1770
|
+
// Global ignores
|
|
1771
|
+
{
|
|
1772
|
+
ignores: ['dist', 'generated', 'node_modules'],
|
|
1773
|
+
},
|
|
1774
|
+
|
|
1775
|
+
// TypeScript source files (with type-checking)
|
|
1776
|
+
{
|
|
1777
|
+
name: 'sources',
|
|
1778
|
+
files: ['src/**/*.ts'],
|
|
1779
|
+
ignores: ['**/*.test.ts', '**/__tests__/**'],
|
|
1780
|
+
languageOptions: {
|
|
1781
|
+
globals: {
|
|
1782
|
+
...globals.node,
|
|
1783
|
+
},
|
|
1784
|
+
parserOptions: {
|
|
1785
|
+
projectService: true,
|
|
1786
|
+
tsconfigRootDir: import.meta.dirname,
|
|
1787
|
+
},
|
|
1788
|
+
},
|
|
1789
|
+
},
|
|
1790
|
+
|
|
1791
|
+
// Test files
|
|
1792
|
+
{
|
|
1793
|
+
name: 'tests',
|
|
1794
|
+
files: ['src/**/*.test.ts', 'src/**/__tests__/**/*.ts'],
|
|
1795
|
+
languageOptions: {
|
|
1796
|
+
globals: {
|
|
1797
|
+
...globals.node,
|
|
1798
|
+
},
|
|
1799
|
+
parserOptions: {
|
|
1800
|
+
projectService: true,
|
|
1801
|
+
tsconfigRootDir: import.meta.dirname,
|
|
1802
|
+
},
|
|
1803
|
+
},
|
|
1804
|
+
},
|
|
1805
|
+
|
|
1806
|
+
// Config files
|
|
1807
|
+
{
|
|
1808
|
+
name: 'ts-configs',
|
|
1809
|
+
files: ['*.config.m?ts', 'eslint.config.mts'],
|
|
1810
|
+
languageOptions: {
|
|
1811
|
+
globals: {
|
|
1812
|
+
...globals.node,
|
|
1813
|
+
},
|
|
1814
|
+
parserOptions: {
|
|
1815
|
+
projectService: false,
|
|
1816
|
+
},
|
|
1817
|
+
},
|
|
1818
|
+
rules: {
|
|
1819
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
1820
|
+
},
|
|
1821
|
+
},
|
|
1822
|
+
|
|
1823
|
+
// JavaScript/MJS files (scripts, configs) \u2014 no TS project, so only
|
|
1824
|
+
// disable the TS-parser-specific rule that doesn't apply without it.
|
|
1825
|
+
{
|
|
1826
|
+
name: 'js-configs',
|
|
1827
|
+
files: ['**/*.js', '**/*.mjs'],
|
|
1828
|
+
languageOptions: {
|
|
1829
|
+
globals: {
|
|
1830
|
+
...globals.node,
|
|
1831
|
+
},
|
|
1832
|
+
parserOptions: {
|
|
1833
|
+
projectService: false,
|
|
1834
|
+
},
|
|
1835
|
+
},
|
|
1836
|
+
rules: {
|
|
1837
|
+
'@typescript-eslint/no-require-imports': 'off',
|
|
1838
|
+
},
|
|
1839
|
+
},
|
|
1840
|
+
|
|
1841
|
+
eslintConfigPrettier,
|
|
1842
|
+
]);
|
|
1750
1843
|
`
|
|
1751
1844
|
},
|
|
1752
1845
|
{
|
|
@@ -1759,7 +1852,9 @@ generated
|
|
|
1759
1852
|
"private": true,
|
|
1760
1853
|
"scripts": {
|
|
1761
1854
|
"build": "test -d src && custom-objects-build --input src --output dist || true",
|
|
1855
|
+
"lint": "pnpm lint:types && pnpm lint:eslint",
|
|
1762
1856
|
"lint:types": "test ! -d src || tsc --noEmit",
|
|
1857
|
+
"lint:eslint": "eslint .",
|
|
1763
1858
|
"test": "vitest run"
|
|
1764
1859
|
},
|
|
1765
1860
|
"dependencies": {
|
|
@@ -1782,8 +1877,20 @@ generated
|
|
|
1782
1877
|
"moduleResolution": "bundler",
|
|
1783
1878
|
"types": ["vitest/globals"]
|
|
1784
1879
|
},
|
|
1880
|
+
"include": ["src/**/*.ts"],
|
|
1785
1881
|
"exclude": ["dist"]
|
|
1786
1882
|
}
|
|
1883
|
+
`
|
|
1884
|
+
},
|
|
1885
|
+
{
|
|
1886
|
+
path: "root/custom-objects/vitest.config.mts",
|
|
1887
|
+
content: `import { defineConfig } from 'vitest/config';
|
|
1888
|
+
|
|
1889
|
+
export default defineConfig({
|
|
1890
|
+
test: {
|
|
1891
|
+
globals: true,
|
|
1892
|
+
},
|
|
1893
|
+
});
|
|
1787
1894
|
`
|
|
1788
1895
|
},
|
|
1789
1896
|
{
|
|
@@ -1901,7 +2008,7 @@ export default defineConfig([
|
|
|
1901
2008
|
"build": "pnpm -r --if-present build",
|
|
1902
2009
|
"lint": "pnpm lint:types && pnpm lint:eslint && pnpm lint:format",
|
|
1903
2010
|
"lint:types": "pnpm -r --if-present lint:types",
|
|
1904
|
-
"lint:eslint": "eslint . --ignore-pattern 'extensions/**' && pnpm -r --filter './extensions/*' --if-present lint:eslint",
|
|
2011
|
+
"lint:eslint": "eslint . --ignore-pattern 'extensions/**' && pnpm -r --filter './extensions/*' --if-present lint:eslint && pnpm -r --filter './custom-objects' --if-present lint:eslint",
|
|
1905
2012
|
"lint:format": "prettier --check .",
|
|
1906
2013
|
"fix:lint": "eslint --fix . --ignore-pattern 'extensions/**' && pnpm -r --filter './extensions/*' --if-present fix:lint",
|
|
1907
2014
|
"fix:format": "prettier --write .",
|
|
@@ -1947,7 +2054,7 @@ declarations:
|
|
|
1947
2054
|
content: `#!/usr/bin/env tsx
|
|
1948
2055
|
/**
|
|
1949
2056
|
* Runs tests across the workspace:
|
|
1950
|
-
* - vitest for script extensions and custom objects (
|
|
2057
|
+
* - vitest for script extensions (extensions/*) and custom objects (custom-objects/)
|
|
1951
2058
|
* - jest for UI extensions (ui/)
|
|
1952
2059
|
*/
|
|
1953
2060
|
import { existsSync, readdirSync } from 'node:fs';
|
|
@@ -1957,6 +2064,8 @@ const hasExtensions =
|
|
|
1957
2064
|
existsSync('extensions') &&
|
|
1958
2065
|
readdirSync('extensions').some((name) => existsSync(\`extensions/\${name}/package.json\`));
|
|
1959
2066
|
|
|
2067
|
+
const hasCustomObjects = existsSync('custom-objects/package.json');
|
|
2068
|
+
|
|
1960
2069
|
const hasUI = existsSync('ui/package.json');
|
|
1961
2070
|
|
|
1962
2071
|
let exitCode = 0;
|
|
@@ -1969,7 +2078,7 @@ function run(cmd: string): void {
|
|
|
1969
2078
|
}
|
|
1970
2079
|
}
|
|
1971
2080
|
|
|
1972
|
-
if (hasExtensions) {
|
|
2081
|
+
if (hasExtensions || hasCustomObjects) {
|
|
1973
2082
|
run('vitest run');
|
|
1974
2083
|
}
|
|
1975
2084
|
|
|
@@ -2733,11 +2842,33 @@ var _ExtensionTemplateManager = class extends import_extensibility_tool_utils4._
|
|
|
2733
2842
|
}
|
|
2734
2843
|
};
|
|
2735
2844
|
|
|
2845
|
+
// src/workspace-versions.json
|
|
2846
|
+
var workspace_versions_default = {
|
|
2847
|
+
"@stripe/extensibility-custom-objects": "0.8.0",
|
|
2848
|
+
"@stripe/extensibility-custom-objects-tools": "0.42.1",
|
|
2849
|
+
"@stripe/extensibility-dev-tools": "0.25.1",
|
|
2850
|
+
"@stripe/extensibility-eslint-plugin": "0.17.1",
|
|
2851
|
+
"@stripe/extensibility-language-server": "0.3.4",
|
|
2852
|
+
"@stripe/extensibility-sdk": "0.27.1",
|
|
2853
|
+
"@stripe/extensibility-test-helpers": "0.2.7"
|
|
2854
|
+
};
|
|
2855
|
+
|
|
2856
|
+
// src/workspace-versions.ts
|
|
2857
|
+
var _workspaceVersions = workspace_versions_default;
|
|
2858
|
+
function _workspaceVersion(packageName) {
|
|
2859
|
+
const v = _workspaceVersions[packageName];
|
|
2860
|
+
if (v === void 0) {
|
|
2861
|
+
throw new Error(
|
|
2862
|
+
`Unknown workspace package "${packageName}". Check workspace-versions.json or run: tsx scripts/src/sync-workspace-versions.ts`
|
|
2863
|
+
);
|
|
2864
|
+
}
|
|
2865
|
+
return v;
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2736
2868
|
// src/templates/extensions/base.ts
|
|
2737
|
-
var import_extensibility_tool_utils9 = require("@stripe/extensibility-tool-utils");
|
|
2738
2869
|
var SDK_PACKAGE_NAME = "@stripe/extensibility-sdk";
|
|
2739
2870
|
var LANGUAGE_SERVER_PACKAGE_NAME = "@stripe/extensibility-language-server";
|
|
2740
|
-
var LANGUAGE_SERVER_PACKAGE_VERSION = `^${
|
|
2871
|
+
var LANGUAGE_SERVER_PACKAGE_VERSION = `^${_workspaceVersion(LANGUAGE_SERVER_PACKAGE_NAME)}`;
|
|
2741
2872
|
function _createExtensionEslintConfigFile(params, context) {
|
|
2742
2873
|
const { id, extensionInterfaceId } = params;
|
|
2743
2874
|
const { fs: fs2 } = context;
|
|
@@ -2780,7 +2911,7 @@ function _createBaseOutput(params, context) {
|
|
|
2780
2911
|
dependencies: {
|
|
2781
2912
|
// Exact pin (no caret) — the SDK is tightly coupled to dev-tools and
|
|
2782
2913
|
// must match the version that generated the extension scaffolding.
|
|
2783
|
-
runtime: [_npmDep(SDK_PACKAGE_NAME,
|
|
2914
|
+
runtime: [_npmDep(SDK_PACKAGE_NAME, _workspaceVersion(SDK_PACKAGE_NAME))],
|
|
2784
2915
|
dev: [_devNpmDep(LANGUAGE_SERVER_PACKAGE_NAME, LANGUAGE_SERVER_PACKAGE_VERSION)]
|
|
2785
2916
|
},
|
|
2786
2917
|
postGenerationHooks: [
|
|
@@ -3039,14 +3170,14 @@ var billing_bill_discount_calculation_default = {
|
|
|
3039
3170
|
[EXTENSION_INTERFACE_ID5]: discountCalculationTemplate
|
|
3040
3171
|
};
|
|
3041
3172
|
|
|
3042
|
-
// src/templates/extensions/billing.
|
|
3043
|
-
var EXTENSION_INTERFACE_ID6 = "billing.
|
|
3044
|
-
var
|
|
3173
|
+
// src/templates/extensions/billing.invoice_collection_options.ts
|
|
3174
|
+
var EXTENSION_INTERFACE_ID6 = "billing.invoice_collection_options";
|
|
3175
|
+
var invoiceCollectionOptionsTemplate = {
|
|
3045
3176
|
hidden: true,
|
|
3046
3177
|
methods: {
|
|
3047
|
-
|
|
3178
|
+
override_options: { implementation_types: ["script"] }
|
|
3048
3179
|
},
|
|
3049
|
-
description: "Use Stripe Scripts to create custom invoice collection
|
|
3180
|
+
description: "Use Stripe Scripts to create custom invoice collection options that controls how your integration handles invoices generated from subscriptions.",
|
|
3050
3181
|
generate: (params, context) => {
|
|
3051
3182
|
const { id } = params;
|
|
3052
3183
|
const { fs: fs2 } = context;
|
|
@@ -3074,15 +3205,15 @@ var invoiceCollectionSettingTemplate = {
|
|
|
3074
3205
|
...base.files
|
|
3075
3206
|
],
|
|
3076
3207
|
methods: {
|
|
3077
|
-
|
|
3208
|
+
override_options: {
|
|
3078
3209
|
implementation_type: "script"
|
|
3079
3210
|
}
|
|
3080
3211
|
}
|
|
3081
3212
|
};
|
|
3082
3213
|
}
|
|
3083
3214
|
};
|
|
3084
|
-
var
|
|
3085
|
-
[EXTENSION_INTERFACE_ID6]:
|
|
3215
|
+
var billing_invoice_collection_options_default = {
|
|
3216
|
+
[EXTENSION_INTERFACE_ID6]: invoiceCollectionOptionsTemplate
|
|
3086
3217
|
};
|
|
3087
3218
|
|
|
3088
3219
|
// src/templates/extensions/billing.prorations.ts
|
|
@@ -3190,7 +3321,7 @@ var DEFAULT_TEMPLATES = {
|
|
|
3190
3321
|
...extend_workflows_custom_action_default,
|
|
3191
3322
|
...billing_customer_balance_application_default,
|
|
3192
3323
|
...billing_bill_discount_calculation_default,
|
|
3193
|
-
...
|
|
3324
|
+
...billing_invoice_collection_options_default,
|
|
3194
3325
|
...billing_prorations_default,
|
|
3195
3326
|
...billing_recurring_billing_item_handling_default
|
|
3196
3327
|
};
|
|
@@ -3203,9 +3334,8 @@ var _templateManager = new _ExtensionTemplateManager(
|
|
|
3203
3334
|
);
|
|
3204
3335
|
|
|
3205
3336
|
// src/templates/root/index.ts
|
|
3206
|
-
var import_extensibility_tool_utils10 = require("@stripe/extensibility-tool-utils");
|
|
3207
3337
|
var EXTENSIBILITY_ESLINT_PLUGIN_PACKAGE_NAME = "@stripe/extensibility-eslint-plugin";
|
|
3208
|
-
var EXTENSIBILITY_ESLINT_PLUGIN_VERSION = `^${
|
|
3338
|
+
var EXTENSIBILITY_ESLINT_PLUGIN_VERSION = `^${_workspaceVersion(EXTENSIBILITY_ESLINT_PLUGIN_PACKAGE_NAME)}`;
|
|
3209
3339
|
var _rootWorkspaceTemplate = {
|
|
3210
3340
|
generate: (params, context) => {
|
|
3211
3341
|
const { fs: fs2 } = context;
|
|
@@ -3260,14 +3390,14 @@ var _rootWorkspaceTemplate = {
|
|
|
3260
3390
|
path: "custom-objects/package.json",
|
|
3261
3391
|
content: fs2.mustache(
|
|
3262
3392
|
{
|
|
3263
|
-
customObjectsVersion:
|
|
3393
|
+
customObjectsVersion: _workspaceVersion(
|
|
3264
3394
|
"@stripe/extensibility-custom-objects"
|
|
3265
3395
|
),
|
|
3266
|
-
sdkVersion:
|
|
3267
|
-
customObjectsToolsVersion:
|
|
3396
|
+
sdkVersion: _workspaceVersion("@stripe/extensibility-sdk"),
|
|
3397
|
+
customObjectsToolsVersion: _workspaceVersion(
|
|
3268
3398
|
"@stripe/extensibility-custom-objects-tools"
|
|
3269
3399
|
),
|
|
3270
|
-
testHelpersVersion:
|
|
3400
|
+
testHelpersVersion: _workspaceVersion("@stripe/extensibility-test-helpers")
|
|
3271
3401
|
},
|
|
3272
3402
|
"custom-objects",
|
|
3273
3403
|
"package.json.mustache"
|
|
@@ -3279,6 +3409,16 @@ var _rootWorkspaceTemplate = {
|
|
|
3279
3409
|
content: fs2.textFile("custom-objects/tsconfig.json"),
|
|
3280
3410
|
precious: true
|
|
3281
3411
|
},
|
|
3412
|
+
{
|
|
3413
|
+
path: "custom-objects/eslint.config.mts",
|
|
3414
|
+
content: fs2.textFile("custom-objects/eslint.config.mts"),
|
|
3415
|
+
precious: true
|
|
3416
|
+
},
|
|
3417
|
+
{
|
|
3418
|
+
path: "custom-objects/vitest.config.mts",
|
|
3419
|
+
content: fs2.textFile("custom-objects/vitest.config.mts"),
|
|
3420
|
+
precious: true
|
|
3421
|
+
},
|
|
3282
3422
|
{
|
|
3283
3423
|
path: "ui/package.json",
|
|
3284
3424
|
content: fs2.textFile("ui/package.json"),
|
|
@@ -3305,7 +3445,7 @@ var _rootWorkspaceTemplate = {
|
|
|
3305
3445
|
_devNpmDep("@types/node", "^20.19.0"),
|
|
3306
3446
|
_devNpmDep(
|
|
3307
3447
|
"@stripe/extensibility-dev-tools",
|
|
3308
|
-
`^${
|
|
3448
|
+
`^${_workspaceVersion("@stripe/extensibility-dev-tools")}`
|
|
3309
3449
|
),
|
|
3310
3450
|
_devNpmDep("concurrently", "^9.2.1"),
|
|
3311
3451
|
_devNpmDep("eslint", "^9.0.0"),
|
|
@@ -3399,7 +3539,7 @@ async function _resolvePackageMetadata(providedId, providedName, packageDir) {
|
|
|
3399
3539
|
name ??= id;
|
|
3400
3540
|
return { id, name, version };
|
|
3401
3541
|
}
|
|
3402
|
-
function runPostGenerationHooks(hooks, workingDir, disabled = false, context = (0,
|
|
3542
|
+
function runPostGenerationHooks(hooks, workingDir, disabled = false, context = (0, import_extensibility_tool_utils9._createCliContext)()) {
|
|
3403
3543
|
if (!hooks || hooks.length === 0 || disabled) {
|
|
3404
3544
|
return Promise.resolve();
|
|
3405
3545
|
}
|
|
@@ -3503,9 +3643,9 @@ function resolveMode(options, projectRoot, packageDir) {
|
|
|
3503
3643
|
workspaceDir: () => packageDir ?? import_node_path3.default.join(projectRoot, "custom-objects"),
|
|
3504
3644
|
generate: async (svc) => {
|
|
3505
3645
|
const customObjectsWorkspaceDir = packageDir ?? import_node_path3.default.join(projectRoot, "custom-objects");
|
|
3506
|
-
const
|
|
3646
|
+
const workspaceScaffoldingExists = (0, import_node_fs2.existsSync)(import_node_path3.default.join(customObjectsWorkspaceDir, "package.json")) && (0, import_node_fs2.existsSync)(import_node_path3.default.join(customObjectsWorkspaceDir, "tsconfig.json")) && (0, import_node_fs2.existsSync)(import_node_path3.default.join(customObjectsWorkspaceDir, "eslint.config.mts"));
|
|
3507
3647
|
const objectResult = await svc.generateCustomObject({ name: objectName });
|
|
3508
|
-
if (
|
|
3648
|
+
if (workspaceScaffoldingExists) {
|
|
3509
3649
|
return objectResult;
|
|
3510
3650
|
}
|
|
3511
3651
|
const workspaceResult = await svc.generateCustomObjectsWorkspace({});
|
|
@@ -3520,11 +3660,11 @@ function resolveMode(options, projectRoot, packageDir) {
|
|
|
3520
3660
|
finalize: async (_svc, _meta, root, _output, context) => {
|
|
3521
3661
|
context.ux.log("\nUpdating stripe-app.yaml...");
|
|
3522
3662
|
const manifestPath = import_node_path3.default.join(root, "stripe-app.yaml");
|
|
3523
|
-
const manifest = await (0,
|
|
3524
|
-
const apiName = (0,
|
|
3663
|
+
const manifest = await (0, import_extensibility_tool_utils9._openStripeAppManifest)(manifestPath);
|
|
3664
|
+
const apiName = (0, import_extensibility_tool_utils9._toSnakeCase)(objectName);
|
|
3525
3665
|
if (!manifest.hasCustomObject(apiName)) {
|
|
3526
3666
|
manifest.addCustomObject(apiName, `custom-objects/src/${apiName}.object.ts`);
|
|
3527
|
-
const tx = (0,
|
|
3667
|
+
const tx = (0, import_extensibility_tool_utils9._beginTransaction)();
|
|
3528
3668
|
tx.adopt(manifest);
|
|
3529
3669
|
const report = await tx.commit();
|
|
3530
3670
|
if (report.written.length > 0) {
|
|
@@ -3618,7 +3758,7 @@ var _defaultServices = {
|
|
|
3618
3758
|
};
|
|
3619
3759
|
},
|
|
3620
3760
|
generateCustomObjectsWorkspace: async (vars) => {
|
|
3621
|
-
const runner = new
|
|
3761
|
+
const runner = new import_extensibility_tool_utils9._GeneratorRunner(import_internal._customObjectsWorkspaceGenerator);
|
|
3622
3762
|
const plan = await runner.plan(vars, {
|
|
3623
3763
|
scope: "project",
|
|
3624
3764
|
projectRoot: process.cwd()
|
|
@@ -3632,7 +3772,7 @@ var _defaultServices = {
|
|
|
3632
3772
|
loadManifest: (manifestPath) => _StripeAppManifest.load(manifestPath),
|
|
3633
3773
|
runHooks: runPostGenerationHooks
|
|
3634
3774
|
};
|
|
3635
|
-
async function _regenAppProjectWorkspace(options, services = _defaultServices, context = (0,
|
|
3775
|
+
async function _regenAppProjectWorkspace(options, services = _defaultServices, context = (0, import_extensibility_tool_utils9._createCliContext)()) {
|
|
3636
3776
|
const isCustomObjectMode = options.templateId === "custom-object";
|
|
3637
3777
|
if (!isCustomObjectMode && !options.packageDir && !options.workspaceId) {
|
|
3638
3778
|
throw new Error("At least one of packageDir or workspaceId is required");
|
|
@@ -3753,7 +3893,7 @@ async function _regenAppProjectWorkspace(options, services = _defaultServices, c
|
|
|
3753
3893
|
}
|
|
3754
3894
|
|
|
3755
3895
|
// src/bin/gen-workspace.ts
|
|
3756
|
-
var logger3 = (0,
|
|
3896
|
+
var logger3 = (0, import_extensibility_tool_utils10._createLogger)({ name: "gen-workspace" });
|
|
3757
3897
|
async function main() {
|
|
3758
3898
|
await (0, import_yargs.default)((0, import_helpers.hideBin)(process.argv)).usage("Regenerate extension or root workspace files from templates").help().version(false).command(
|
|
3759
3899
|
"$0",
|
|
@@ -3816,7 +3956,7 @@ async function main() {
|
|
|
3816
3956
|
"Generate a new custom object definition and test"
|
|
3817
3957
|
),
|
|
3818
3958
|
async (args) => {
|
|
3819
|
-
const ctx = (0,
|
|
3959
|
+
const ctx = (0, import_extensibility_tool_utils10._createCliContext)();
|
|
3820
3960
|
const {
|
|
3821
3961
|
root,
|
|
3822
3962
|
templateId,
|
|
@@ -3848,7 +3988,7 @@ async function main() {
|
|
|
3848
3988
|
void 0,
|
|
3849
3989
|
ctx
|
|
3850
3990
|
);
|
|
3851
|
-
(0,
|
|
3991
|
+
(0, import_extensibility_tool_utils10._writeJsonOutput)(outputPath, { success: true });
|
|
3852
3992
|
}
|
|
3853
3993
|
).parse();
|
|
3854
3994
|
}
|