@stackframe/stack-shared 2.8.58 → 2.8.60
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/config/migrate-catalogs-to-product-lines.d.mts +12 -0
- package/dist/config/migrate-catalogs-to-product-lines.d.ts +12 -0
- package/dist/config/migrate-catalogs-to-product-lines.js +211 -0
- package/dist/config/migrate-catalogs-to-product-lines.js.map +1 -0
- package/dist/config/schema-fuzzer.test.js +17 -6
- package/dist/config/schema-fuzzer.test.js.map +1 -1
- package/dist/config/schema.d.mts +181 -157
- package/dist/config/schema.d.ts +181 -157
- package/dist/config/schema.js +39 -8
- package/dist/config/schema.js.map +1 -1
- package/dist/esm/config/migrate-catalogs-to-product-lines.js +186 -0
- package/dist/esm/config/migrate-catalogs-to-product-lines.js.map +1 -0
- package/dist/esm/config/schema-fuzzer.test.js +17 -6
- package/dist/esm/config/schema-fuzzer.test.js.map +1 -1
- package/dist/esm/config/schema.js +40 -9
- package/dist/esm/config/schema.js.map +1 -1
- package/dist/esm/interface/client-interface.js +111 -21
- package/dist/esm/interface/client-interface.js.map +1 -1
- package/dist/esm/interface/crud/products.js +12 -1
- package/dist/esm/interface/crud/products.js.map +1 -1
- package/dist/esm/interface/server-interface.js +38 -0
- package/dist/esm/interface/server-interface.js.map +1 -1
- package/dist/esm/known-errors.js +24 -0
- package/dist/esm/known-errors.js.map +1 -1
- package/dist/esm/schema-fields.js +1 -1
- package/dist/esm/schema-fields.js.map +1 -1
- package/dist/interface/client-interface.d.mts +31 -0
- package/dist/interface/client-interface.d.ts +31 -0
- package/dist/interface/client-interface.js +111 -21
- package/dist/interface/client-interface.js.map +1 -1
- package/dist/interface/crud/products.d.mts +77 -0
- package/dist/interface/crud/products.d.ts +77 -0
- package/dist/interface/crud/products.js +12 -1
- package/dist/interface/crud/products.js.map +1 -1
- package/dist/interface/server-interface.d.mts +23 -0
- package/dist/interface/server-interface.d.ts +23 -0
- package/dist/interface/server-interface.js +38 -0
- package/dist/interface/server-interface.js.map +1 -1
- package/dist/known-errors.d.mts +6 -0
- package/dist/known-errors.d.ts +6 -0
- package/dist/known-errors.js +24 -0
- package/dist/known-errors.js.map +1 -1
- package/dist/schema-fields.d.mts +4 -4
- package/dist/schema-fields.d.ts +4 -4
- package/dist/schema-fields.js +1 -1
- package/dist/schema-fields.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migrates the old "catalogs" format to "productLines", including:
|
|
3
|
+
* 1. Inferring customerType for each catalog from its products (since old catalogs didn't have customerType)
|
|
4
|
+
* 2. Removing empty catalogs (those with no products) since they can't have customerType inferred
|
|
5
|
+
* 3. Renaming payments.catalogs -> payments.productLines
|
|
6
|
+
* 4. Renaming payments.products.*.catalogId -> payments.products.*.productLineId
|
|
7
|
+
*
|
|
8
|
+
* This handles all config formats (nested objects, flat dot-notation, or mixed).
|
|
9
|
+
*/
|
|
10
|
+
declare function migrateCatalogsToProductLines(obj: Record<string, any>): Record<string, any>;
|
|
11
|
+
|
|
12
|
+
export { migrateCatalogsToProductLines };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migrates the old "catalogs" format to "productLines", including:
|
|
3
|
+
* 1. Inferring customerType for each catalog from its products (since old catalogs didn't have customerType)
|
|
4
|
+
* 2. Removing empty catalogs (those with no products) since they can't have customerType inferred
|
|
5
|
+
* 3. Renaming payments.catalogs -> payments.productLines
|
|
6
|
+
* 4. Renaming payments.products.*.catalogId -> payments.products.*.productLineId
|
|
7
|
+
*
|
|
8
|
+
* This handles all config formats (nested objects, flat dot-notation, or mixed).
|
|
9
|
+
*/
|
|
10
|
+
declare function migrateCatalogsToProductLines(obj: Record<string, any>): Record<string, any>;
|
|
11
|
+
|
|
12
|
+
export { migrateCatalogsToProductLines };
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/config/migrate-catalogs-to-product-lines.ts
|
|
21
|
+
var migrate_catalogs_to_product_lines_exports = {};
|
|
22
|
+
__export(migrate_catalogs_to_product_lines_exports, {
|
|
23
|
+
migrateCatalogsToProductLines: () => migrateCatalogsToProductLines
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(migrate_catalogs_to_product_lines_exports);
|
|
26
|
+
var import_errors = require("../utils/errors.js");
|
|
27
|
+
var import_objects = require("../utils/objects.js");
|
|
28
|
+
function renameProperty(obj, oldPath, newName) {
|
|
29
|
+
const pathCond = typeof oldPath === "function" ? oldPath : (p) => p.join(".") === oldPath;
|
|
30
|
+
const pathMapper = typeof newName === "function" ? newName : (p) => newName;
|
|
31
|
+
const res = Array.isArray(obj) ? [] : {};
|
|
32
|
+
for (const [key, originalValue] of (0, import_objects.typedEntries)(obj)) {
|
|
33
|
+
const path = key.split(".");
|
|
34
|
+
for (let i = 0; i < path.length; i++) {
|
|
35
|
+
const pathPrefix = path.slice(0, i + 1);
|
|
36
|
+
if (pathCond(pathPrefix)) {
|
|
37
|
+
const name = pathMapper(pathPrefix);
|
|
38
|
+
if (name.includes(".")) throw new import_errors.StackAssertionError(`newName must not contain a dot. Provided: ${name}`);
|
|
39
|
+
path[i] = name;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const value = (0, import_objects.isObjectLike)(originalValue) ? renameProperty(originalValue, (p) => pathCond([...path, ...p]), (p) => pathMapper([...path, ...p])) : originalValue;
|
|
43
|
+
(0, import_objects.set)(res, path.join("."), value);
|
|
44
|
+
}
|
|
45
|
+
return res;
|
|
46
|
+
}
|
|
47
|
+
function migrateCatalogsToProductLines(obj) {
|
|
48
|
+
const catalogCustomerTypes = /* @__PURE__ */ new Map();
|
|
49
|
+
collectCatalogCustomerTypes(obj, [], catalogCustomerTypes);
|
|
50
|
+
const allCatalogIds = /* @__PURE__ */ new Set();
|
|
51
|
+
findAllCatalogIds(obj, [], allCatalogIds);
|
|
52
|
+
let res = { ...obj };
|
|
53
|
+
for (const catalogId of allCatalogIds) {
|
|
54
|
+
const customerType = catalogCustomerTypes.get(catalogId);
|
|
55
|
+
if (customerType) {
|
|
56
|
+
res = addCustomerTypeToCatalog(res, catalogId, customerType);
|
|
57
|
+
} else {
|
|
58
|
+
res = removeCatalog(res, catalogId);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
res = renameProperty(res, "payments.catalogs", "productLines");
|
|
62
|
+
res = renameProperty(res, (p) => p.length === 4 && p[0] === "payments" && p[1] === "products" && p[3] === "catalogId", () => "productLineId");
|
|
63
|
+
return res;
|
|
64
|
+
}
|
|
65
|
+
function collectCatalogCustomerTypes(obj, basePath, result) {
|
|
66
|
+
for (const [key, value] of (0, import_objects.typedEntries)(obj)) {
|
|
67
|
+
const keyParts = key.split(".");
|
|
68
|
+
const fullPath = [...basePath, ...keyParts];
|
|
69
|
+
if (basePath.length === 0 && fullPath.length === 4 && fullPath[0] === "payments" && fullPath[1] === "products" && fullPath[3] === "catalogId") {
|
|
70
|
+
if (typeof value === "string") {
|
|
71
|
+
const productId = fullPath[2];
|
|
72
|
+
const customerTypeKey = `payments.products.${productId}.customerType`;
|
|
73
|
+
if (customerTypeKey in obj && typeof obj[customerTypeKey] === "string") {
|
|
74
|
+
result.set(value, obj[customerTypeKey]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (fullPath.length === 3 && fullPath[0] === "payments" && fullPath[1] === "products" && (0, import_objects.isObjectLike)(value)) {
|
|
79
|
+
const catalogId = findPropertyValue(value, "catalogId") ?? findPropertyValue(value, "productLineId");
|
|
80
|
+
const customerType = findPropertyValue(value, "customerType");
|
|
81
|
+
if (catalogId && typeof catalogId === "string" && customerType && typeof customerType === "string") {
|
|
82
|
+
result.set(catalogId, customerType);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if ((0, import_objects.isObjectLike)(value)) {
|
|
86
|
+
collectCatalogCustomerTypes(value, fullPath, result);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function findPropertyValue(obj, propertyName) {
|
|
91
|
+
if (propertyName in obj) {
|
|
92
|
+
return obj[propertyName];
|
|
93
|
+
}
|
|
94
|
+
for (const key of Object.keys(obj)) {
|
|
95
|
+
const parts = key.split(".");
|
|
96
|
+
if (parts[parts.length - 1] === propertyName) {
|
|
97
|
+
return obj[key];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return void 0;
|
|
101
|
+
}
|
|
102
|
+
function findAllCatalogIds(obj, basePath, result) {
|
|
103
|
+
for (const [key, value] of (0, import_objects.typedEntries)(obj)) {
|
|
104
|
+
const keyParts = key.split(".");
|
|
105
|
+
const fullPath = [...basePath, ...keyParts];
|
|
106
|
+
if (fullPath.length >= 3 && fullPath[0] === "payments" && fullPath[1] === "catalogs") {
|
|
107
|
+
const catalogId = fullPath[2];
|
|
108
|
+
result.add(catalogId);
|
|
109
|
+
}
|
|
110
|
+
if ((0, import_objects.isObjectLike)(value)) {
|
|
111
|
+
findAllCatalogIds(value, fullPath, result);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function removeCatalog(obj, catalogId) {
|
|
116
|
+
if (Array.isArray(obj)) {
|
|
117
|
+
return obj;
|
|
118
|
+
}
|
|
119
|
+
const res = {};
|
|
120
|
+
for (const [key, value] of (0, import_objects.typedEntries)(obj)) {
|
|
121
|
+
const keyParts = key.split(".");
|
|
122
|
+
if (keyParts.length >= 3 && keyParts[0] === "payments" && keyParts[1] === "catalogs" && keyParts[2] === catalogId) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (key === `payments.catalogs.${catalogId}`) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (Array.isArray(value)) {
|
|
129
|
+
res[key] = value;
|
|
130
|
+
} else if ((0, import_objects.isObjectLike)(value)) {
|
|
131
|
+
const processed = removeCatalog(value, catalogId);
|
|
132
|
+
if (key === "payments" && (0, import_objects.isObjectLike)(processed) && "catalogs" in processed) {
|
|
133
|
+
const catalogs = processed.catalogs;
|
|
134
|
+
if ((0, import_objects.isObjectLike)(catalogs) && catalogId in catalogs) {
|
|
135
|
+
const { [catalogId]: _, ...rest } = catalogs;
|
|
136
|
+
res[key] = { ...processed, catalogs: rest };
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (key === "payments.catalogs" && (0, import_objects.isObjectLike)(processed) && catalogId in processed) {
|
|
141
|
+
const { [catalogId]: _, ...rest } = processed;
|
|
142
|
+
res[key] = rest;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
res[key] = processed;
|
|
146
|
+
} else {
|
|
147
|
+
res[key] = value;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return res;
|
|
151
|
+
}
|
|
152
|
+
function addCustomerTypeToCatalog(obj, catalogId, customerType) {
|
|
153
|
+
if (Array.isArray(obj)) {
|
|
154
|
+
return obj;
|
|
155
|
+
}
|
|
156
|
+
const res = {};
|
|
157
|
+
for (const [key, value] of (0, import_objects.typedEntries)(obj)) {
|
|
158
|
+
if (Array.isArray(value)) {
|
|
159
|
+
res[key] = value;
|
|
160
|
+
} else if ((0, import_objects.isObjectLike)(value)) {
|
|
161
|
+
res[key] = addCustomerTypeToCatalog(value, catalogId, customerType);
|
|
162
|
+
} else {
|
|
163
|
+
res[key] = value;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const payments = res.payments;
|
|
167
|
+
if (payments && (0, import_objects.isObjectLike)(payments) && !Array.isArray(payments) && typeof payments !== "function") {
|
|
168
|
+
const paymentsObj = payments;
|
|
169
|
+
const catalogs = paymentsObj.catalogs;
|
|
170
|
+
if (catalogs && (0, import_objects.isObjectLike)(catalogs) && !Array.isArray(catalogs) && typeof catalogs !== "function") {
|
|
171
|
+
const catalogsObj = catalogs;
|
|
172
|
+
const catalog = catalogsObj[catalogId];
|
|
173
|
+
if (catalog && (0, import_objects.isObjectLike)(catalog)) {
|
|
174
|
+
if (!("customerType" in catalog)) {
|
|
175
|
+
catalogsObj[catalogId] = { ...catalog, customerType };
|
|
176
|
+
}
|
|
177
|
+
return res;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const paymentsCatalogs = res["payments.catalogs"];
|
|
182
|
+
if (paymentsCatalogs && (0, import_objects.isObjectLike)(paymentsCatalogs) && !Array.isArray(paymentsCatalogs) && typeof paymentsCatalogs !== "function") {
|
|
183
|
+
const catalogs = paymentsCatalogs;
|
|
184
|
+
if (catalogId in catalogs && (0, import_objects.isObjectLike)(catalogs[catalogId])) {
|
|
185
|
+
if (!("customerType" in catalogs[catalogId])) {
|
|
186
|
+
catalogs[catalogId] = { ...catalogs[catalogId], customerType };
|
|
187
|
+
}
|
|
188
|
+
return res;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const catalogKey = `payments.catalogs.${catalogId}`;
|
|
192
|
+
if (catalogKey in res && (0, import_objects.isObjectLike)(res[catalogKey])) {
|
|
193
|
+
if (!("customerType" in res[catalogKey])) {
|
|
194
|
+
res[catalogKey] = { ...res[catalogKey], customerType };
|
|
195
|
+
}
|
|
196
|
+
return res;
|
|
197
|
+
}
|
|
198
|
+
const customerTypeKey = `payments.catalogs.${catalogId}.customerType`;
|
|
199
|
+
for (const key of Object.keys(res)) {
|
|
200
|
+
if (key.startsWith(`payments.catalogs.${catalogId}.`) && key !== customerTypeKey) {
|
|
201
|
+
res[customerTypeKey] = customerType;
|
|
202
|
+
return res;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return res;
|
|
206
|
+
}
|
|
207
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
208
|
+
0 && (module.exports = {
|
|
209
|
+
migrateCatalogsToProductLines
|
|
210
|
+
});
|
|
211
|
+
//# sourceMappingURL=migrate-catalogs-to-product-lines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/config/migrate-catalogs-to-product-lines.ts"],"sourcesContent":["import { StackAssertionError } from \"../utils/errors\";\nimport { isObjectLike, set, typedEntries } from \"../utils/objects\";\n\n/**\n * Renames properties in an object based on a path condition.\n * This is a local copy to avoid circular dependencies with schema.ts.\n */\nfunction renameProperty(obj: Record<string, any>, oldPath: string | ((path: string[]) => boolean), newName: string | ((path: string[]) => string)): any {\n const pathCond = typeof oldPath === \"function\" ? oldPath : (p: string[]) => p.join(\".\") === oldPath;\n const pathMapper = typeof newName === \"function\" ? newName : (p: string[]) => (newName as string);\n\n const res: Record<string, any> = Array.isArray(obj) ? [] : {};\n for (const [key, originalValue] of typedEntries(obj)) {\n const path = key.split(\".\");\n\n for (let i = 0; i < path.length; i++) {\n const pathPrefix = path.slice(0, i + 1);\n if (pathCond(pathPrefix)) {\n const name = pathMapper(pathPrefix);\n if (name.includes(\".\")) throw new StackAssertionError(`newName must not contain a dot. Provided: ${name}`);\n path[i] = name;\n }\n }\n\n const value = isObjectLike(originalValue) ? renameProperty(originalValue, p => pathCond([...path, ...p]), p => pathMapper([...path, ...p])) : originalValue;\n set(res, path.join(\".\"), value);\n }\n\n return res;\n}\n\n/**\n * Migrates the old \"catalogs\" format to \"productLines\", including:\n * 1. Inferring customerType for each catalog from its products (since old catalogs didn't have customerType)\n * 2. Removing empty catalogs (those with no products) since they can't have customerType inferred\n * 3. Renaming payments.catalogs -> payments.productLines\n * 4. Renaming payments.products.*.catalogId -> payments.products.*.productLineId\n *\n * This handles all config formats (nested objects, flat dot-notation, or mixed).\n */\nexport function migrateCatalogsToProductLines(obj: Record<string, any>): Record<string, any> {\n // Step 1: Collect catalogId -> customerType mappings from products\n const catalogCustomerTypes = new Map<string, string>();\n collectCatalogCustomerTypes(obj, [], catalogCustomerTypes);\n\n // Step 2: Find all catalog IDs that exist\n const allCatalogIds = new Set<string>();\n findAllCatalogIds(obj, [], allCatalogIds);\n\n // Step 3: Add customerType keys for catalogs that need them\n let res = { ...obj };\n for (const catalogId of allCatalogIds) {\n const customerType = catalogCustomerTypes.get(catalogId);\n if (customerType) {\n // Find the format used for this catalog and add customerType in the same format\n res = addCustomerTypeToCatalog(res, catalogId, customerType);\n } else {\n // Empty catalog (no products) - remove it since we can't infer customerType\n res = removeCatalog(res, catalogId);\n }\n }\n\n // Step 4: Rename catalogs -> productLines\n res = renameProperty(res, \"payments.catalogs\", \"productLines\");\n\n // Step 5: Rename catalogId -> productLineId in products\n res = renameProperty(res, (p) => p.length === 4 && p[0] === \"payments\" && p[1] === \"products\" && p[3] === \"catalogId\", () => \"productLineId\");\n\n return res;\n}\n\n/**\n * Recursively collects catalogId -> customerType mappings from products.\n * Handles both nested and flat config formats.\n */\nfunction collectCatalogCustomerTypes(\n obj: Record<string, any>,\n basePath: string[],\n result: Map<string, string>\n): void {\n for (const [key, value] of typedEntries(obj)) {\n const keyParts = key.split(\".\");\n const fullPath = [...basePath, ...keyParts];\n\n // Check for flat format at ROOT level only: payments.products.<productId>.catalogId\n // We check basePath.length === 0 to ensure we're at root and key contains the full path\n if (basePath.length === 0 && fullPath.length === 4 && fullPath[0] === \"payments\" && fullPath[1] === \"products\" && fullPath[3] === \"catalogId\") {\n if (typeof value === \"string\") {\n const productId = fullPath[2];\n // Look for customerType in the same flat format\n const customerTypeKey = `payments.products.${productId}.customerType`;\n if (customerTypeKey in obj && typeof obj[customerTypeKey] === \"string\") {\n result.set(value, obj[customerTypeKey]);\n }\n }\n }\n\n // Check for nested format: payments.products.<productId> with object value\n if (fullPath.length === 3 && fullPath[0] === \"payments\" && fullPath[1] === \"products\" && isObjectLike(value)) {\n const catalogId = findPropertyValue(value, \"catalogId\") ?? findPropertyValue(value, \"productLineId\");\n const customerType = findPropertyValue(value, \"customerType\");\n if (catalogId && typeof catalogId === \"string\" && customerType && typeof customerType === \"string\") {\n result.set(catalogId, customerType);\n }\n }\n\n if (isObjectLike(value)) {\n collectCatalogCustomerTypes(value, fullPath, result);\n }\n }\n}\n\n/**\n * Finds a property value in an object, handling both direct properties and dot-notation keys.\n */\nfunction findPropertyValue(obj: Record<string, any>, propertyName: string): any {\n // Direct property\n if (propertyName in obj) {\n return obj[propertyName];\n }\n // Check for dot-notation keys that end with the property name\n for (const key of Object.keys(obj)) {\n const parts = key.split(\".\");\n if (parts[parts.length - 1] === propertyName) {\n return obj[key];\n }\n }\n return undefined;\n}\n\n/**\n * Finds all catalog IDs that exist in the config.\n */\nfunction findAllCatalogIds(\n obj: Record<string, any>,\n basePath: string[],\n result: Set<string>\n): void {\n for (const [key, value] of typedEntries(obj)) {\n const keyParts = key.split(\".\");\n const fullPath = [...basePath, ...keyParts];\n\n // Check for catalog entry at payments.catalogs.<catalogId>\n if (fullPath.length >= 3 && fullPath[0] === \"payments\" && fullPath[1] === \"catalogs\") {\n const catalogId = fullPath[2];\n result.add(catalogId);\n }\n\n if (isObjectLike(value)) {\n findAllCatalogIds(value, fullPath, result);\n }\n }\n}\n\n/**\n * Removes a catalog from the config in any format (nested or flat).\n */\nfunction removeCatalog(obj: Record<string, any>, catalogId: string): Record<string, any> {\n // Don't process arrays - they should be copied as-is\n if (Array.isArray(obj)) {\n return obj;\n }\n\n const res: Record<string, any> = {};\n\n for (const [key, value] of typedEntries(obj)) {\n const keyParts = key.split(\".\");\n\n // Check if this key is for the catalog we want to remove\n // Format 4: \"payments.catalogs.<catalogId>.displayName\" or similar flat keys\n if (keyParts.length >= 3 && keyParts[0] === \"payments\" && keyParts[1] === \"catalogs\" && keyParts[2] === catalogId) {\n // Skip this key - don't copy it\n continue;\n }\n\n // Format 3: \"payments.catalogs.<catalogId>\" as a single key\n if (key === `payments.catalogs.${catalogId}`) {\n continue;\n }\n\n if (Array.isArray(value)) {\n res[key] = value;\n } else if (isObjectLike(value)) {\n const processed = removeCatalog(value, catalogId);\n // Check if we need to remove the catalog from nested structures\n if (key === \"payments\" && isObjectLike(processed) && \"catalogs\" in processed) {\n const catalogs = processed.catalogs;\n if (isObjectLike(catalogs) && catalogId in catalogs) {\n const { [catalogId]: _, ...rest } = catalogs as Record<string, any>;\n res[key] = { ...processed, catalogs: rest };\n continue;\n }\n }\n // Format 2: \"payments.catalogs\" as a key with nested catalog\n if (key === \"payments.catalogs\" && isObjectLike(processed) && catalogId in processed) {\n const { [catalogId]: _, ...rest } = processed as Record<string, any>;\n res[key] = rest;\n continue;\n }\n res[key] = processed;\n } else {\n res[key] = value;\n }\n }\n\n return res;\n}\n\n/**\n * Adds customerType to a catalog in the appropriate format.\n */\nfunction addCustomerTypeToCatalog(obj: Record<string, any>, catalogId: string, customerType: string): Record<string, any> {\n // Don't process arrays - they should be copied as-is\n if (Array.isArray(obj)) {\n return obj;\n }\n\n const res: Record<string, any> = {};\n\n // First, copy all existing properties\n for (const [key, value] of typedEntries(obj)) {\n if (Array.isArray(value)) {\n // Copy arrays directly without processing\n res[key] = value;\n } else if (isObjectLike(value)) {\n res[key] = addCustomerTypeToCatalog(value, catalogId, customerType);\n } else {\n res[key] = value;\n }\n }\n\n // Check what format the catalog uses\n // Format 1: { payments: { catalogs: { [catalogId]: { ... } } } }\n const payments = res.payments;\n if (payments && isObjectLike(payments) && !Array.isArray(payments) && typeof payments !== \"function\") {\n const paymentsObj = payments as Record<string, any>;\n const catalogs = paymentsObj.catalogs;\n if (catalogs && isObjectLike(catalogs) && !Array.isArray(catalogs) && typeof catalogs !== \"function\") {\n const catalogsObj = catalogs as Record<string, any>;\n const catalog = catalogsObj[catalogId];\n if (catalog && isObjectLike(catalog)) {\n if (!(\"customerType\" in catalog)) {\n catalogsObj[catalogId] = { ...catalog, customerType };\n }\n return res;\n }\n }\n }\n\n // Format 2: { \"payments.catalogs\": { [catalogId]: { ... } } }\n const paymentsCatalogs = res[\"payments.catalogs\"];\n if (paymentsCatalogs && isObjectLike(paymentsCatalogs) && !Array.isArray(paymentsCatalogs) && typeof paymentsCatalogs !== \"function\") {\n const catalogs = paymentsCatalogs as Record<string, any>;\n if (catalogId in catalogs && isObjectLike(catalogs[catalogId])) {\n if (!(\"customerType\" in catalogs[catalogId])) {\n catalogs[catalogId] = { ...catalogs[catalogId], customerType };\n }\n return res;\n }\n }\n\n // Format 3: { \"payments.catalogs.[catalogId]\": { ... } }\n const catalogKey = `payments.catalogs.${catalogId}`;\n if (catalogKey in res && isObjectLike(res[catalogKey])) {\n if (!(\"customerType\" in res[catalogKey])) {\n res[catalogKey] = { ...res[catalogKey], customerType };\n }\n return res;\n }\n\n // Format 4: { \"payments.catalogs.[catalogId].displayName\": \"...\" }\n // Need to add a new key for customerType\n const customerTypeKey = `payments.catalogs.${catalogId}.customerType`;\n for (const key of Object.keys(res)) {\n if (key.startsWith(`payments.catalogs.${catalogId}.`) && key !== customerTypeKey) {\n // Found a flat key for this catalog, add customerType in same format\n res[customerTypeKey] = customerType;\n return res;\n }\n }\n\n return res;\n}\n\n// Tests\nundefined?.test(\"migrateCatalogsToProductLines - basic migrations\", ({ expect }) => {\n // Basic nested format\n expect(migrateCatalogsToProductLines({\n payments: {\n catalogs: {\n myCatalog: { displayName: \"My Catalog\" }\n },\n products: {\n myProduct: { catalogId: \"myCatalog\", customerType: \"user\", prices: {} }\n }\n }\n })).toEqual({\n payments: {\n productLines: {\n myCatalog: { displayName: \"My Catalog\", customerType: \"user\" }\n },\n products: {\n myProduct: { productLineId: \"myCatalog\", customerType: \"user\", prices: {} }\n }\n }\n });\n\n // Flat format\n expect(migrateCatalogsToProductLines({\n \"payments.catalogs.myCatalog\": { displayName: \"My Catalog\" },\n \"payments.products.myProduct.catalogId\": \"myCatalog\",\n \"payments.products.myProduct.customerType\": \"user\",\n })).toEqual({\n \"payments.productLines.myCatalog\": { displayName: \"My Catalog\", customerType: \"user\" },\n \"payments.products.myProduct.productLineId\": \"myCatalog\",\n \"payments.products.myProduct.customerType\": \"user\",\n });\n\n // Mixed format\n expect(migrateCatalogsToProductLines({\n payments: {\n catalogs: { myCatalog: { displayName: \"My Catalog\" } }\n },\n \"payments.products.myProduct\": { catalogId: \"myCatalog\", customerType: \"user\" }\n })).toEqual({\n payments: {\n productLines: { myCatalog: { displayName: \"My Catalog\", customerType: \"user\" } }\n },\n \"payments.products.myProduct\": { productLineId: \"myCatalog\", customerType: \"user\" }\n });\n});\n\nundefined?.test(\"migrateCatalogsToProductLines - does not overwrite existing customerType\", ({ expect }) => {\n // If catalog already has customerType, don't overwrite it\n expect(migrateCatalogsToProductLines({\n payments: {\n catalogs: {\n myCatalog: { displayName: \"My Catalog\", customerType: \"team\" }\n },\n products: {\n myProduct: { catalogId: \"myCatalog\", customerType: \"user\", prices: {} }\n }\n }\n })).toEqual({\n payments: {\n productLines: {\n myCatalog: { displayName: \"My Catalog\", customerType: \"team\" }\n },\n products: {\n myProduct: { productLineId: \"myCatalog\", customerType: \"user\", prices: {} }\n }\n }\n });\n});\n\nundefined?.test(\"migrateCatalogsToProductLines - multiple catalogs and products\", ({ expect }) => {\n expect(migrateCatalogsToProductLines({\n payments: {\n catalogs: {\n userPlans: { displayName: \"User Plans\" },\n teamPlans: { displayName: \"Team Plans\" }\n },\n products: {\n userBasic: { catalogId: \"userPlans\", customerType: \"user\", prices: {} },\n userPro: { catalogId: \"userPlans\", customerType: \"user\", prices: {} },\n teamBasic: { catalogId: \"teamPlans\", customerType: \"team\", prices: {} }\n }\n }\n })).toEqual({\n payments: {\n productLines: {\n userPlans: { displayName: \"User Plans\", customerType: \"user\" },\n teamPlans: { displayName: \"Team Plans\", customerType: \"team\" }\n },\n products: {\n userBasic: { productLineId: \"userPlans\", customerType: \"user\", prices: {} },\n userPro: { productLineId: \"userPlans\", customerType: \"user\", prices: {} },\n teamBasic: { productLineId: \"teamPlans\", customerType: \"team\", prices: {} }\n }\n }\n });\n});\n\nundefined?.test(\"migrateCatalogsToProductLines - catalog without products is removed\", ({ expect }) => {\n // Catalog without any products should be removed since we can't infer customerType\n expect(migrateCatalogsToProductLines({\n payments: {\n catalogs: {\n emptyCatalog: { displayName: \"Empty\" }\n },\n products: {}\n }\n })).toEqual({\n payments: {\n productLines: {},\n products: {}\n }\n });\n});\n\nundefined?.test(\"migrateCatalogsToProductLines - products without catalogId\", ({ expect }) => {\n // Catalogs without any products referencing them should be removed\n expect(migrateCatalogsToProductLines({\n payments: {\n catalogs: {\n myCatalog: { displayName: \"My Catalog\" }\n },\n products: {\n standalone: { customerType: \"user\", prices: {} }\n }\n }\n })).toEqual({\n payments: {\n productLines: {},\n products: {\n standalone: { customerType: \"user\", prices: {} }\n }\n }\n });\n});\n\nundefined?.test(\"migrateCatalogsToProductLines - deeply nested flat format\", ({ expect }) => {\n expect(migrateCatalogsToProductLines({\n \"payments.catalogs.myCatalog.displayName\": \"My Catalog\",\n \"payments.products.myProduct.catalogId\": \"myCatalog\",\n \"payments.products.myProduct.customerType\": \"user\",\n \"payments.products.myProduct.prices\": {},\n })).toEqual({\n \"payments.productLines.myCatalog.displayName\": \"My Catalog\",\n \"payments.productLines.myCatalog.customerType\": \"user\",\n \"payments.products.myProduct.productLineId\": \"myCatalog\",\n \"payments.products.myProduct.customerType\": \"user\",\n \"payments.products.myProduct.prices\": {},\n });\n});\n\nundefined?.test(\"migrateCatalogsToProductLines - no catalogs\", ({ expect }) => {\n // Config without catalogs should pass through unchanged (except productLineId rename)\n expect(migrateCatalogsToProductLines({\n payments: {\n products: {\n myProduct: { catalogId: \"someCatalog\", customerType: \"user\" }\n }\n }\n })).toEqual({\n payments: {\n products: {\n myProduct: { productLineId: \"someCatalog\", customerType: \"user\" }\n }\n }\n });\n});\n\nundefined?.test(\"migrateCatalogsToProductLines - already migrated (productLines)\", ({ expect }) => {\n // Already has productLines, should not change customerType\n expect(migrateCatalogsToProductLines({\n payments: {\n productLines: {\n myLine: { displayName: \"My Line\", customerType: \"team\" }\n },\n products: {\n myProduct: { productLineId: \"myLine\", customerType: \"team\" }\n }\n }\n })).toEqual({\n payments: {\n productLines: {\n myLine: { displayName: \"My Line\", customerType: \"team\" }\n },\n products: {\n myProduct: { productLineId: \"myLine\", customerType: \"team\" }\n }\n }\n });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAoC;AACpC,qBAAgD;AAMhD,SAAS,eAAe,KAA0B,SAAiD,SAAqD;AACtJ,QAAM,WAAW,OAAO,YAAY,aAAa,UAAU,CAAC,MAAgB,EAAE,KAAK,GAAG,MAAM;AAC5F,QAAM,aAAa,OAAO,YAAY,aAAa,UAAU,CAAC,MAAiB;AAE/E,QAAM,MAA2B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;AAC5D,aAAW,CAAC,KAAK,aAAa,SAAK,6BAAa,GAAG,GAAG;AACpD,UAAM,OAAO,IAAI,MAAM,GAAG;AAE1B,aAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,YAAM,aAAa,KAAK,MAAM,GAAG,IAAI,CAAC;AACtC,UAAI,SAAS,UAAU,GAAG;AACxB,cAAM,OAAO,WAAW,UAAU;AAClC,YAAI,KAAK,SAAS,GAAG,EAAG,OAAM,IAAI,kCAAoB,6CAA6C,IAAI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tD,QAAI,EAAE,kBAAkB,IAAI,UAAU,IAAI;AACxC,UAAI,UAAU,IAAI,EAAE,GAAG,IAAI,UAAU,GAAG,aAAa;AAAA,IACvD;AACA,WAAO;AAAA,EACT;AAIA,QAAM,kBAAkB,qBAAqB,SAAS;AACtD,aAAW,OAAO,OAAO,KAAK,GAAG,GAAG;AAClC,QAAI,IAAI,WAAW,qBAAqB,SAAS,GAAG,KAAK,QAAQ,iBAAiB;AAEhF,UAAI,eAAe,IAAI;AACvB,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -48,18 +48,27 @@ var branchSchemaFuzzerConfig = [{
|
|
|
48
48
|
}]
|
|
49
49
|
}],
|
|
50
50
|
payments: [{
|
|
51
|
+
blockNewPurchases: [false, true],
|
|
51
52
|
testMode: [false, true],
|
|
52
53
|
autoPay: [{
|
|
53
54
|
interval: [[[0, 1, -3, 100, 0.333, Infinity], ["day", "week", "month", "year"]]]
|
|
54
55
|
}],
|
|
56
|
+
productLines: [{
|
|
57
|
+
"some-product-line-id": [{
|
|
58
|
+
displayName: ["Some Product Line", "Some Other Product Line"],
|
|
59
|
+
customerType: ["user", "team", "custom"]
|
|
60
|
+
}]
|
|
61
|
+
}],
|
|
55
62
|
catalogs: [{
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
// ensure migration works
|
|
64
|
+
"some-product-line-id": [{
|
|
65
|
+
displayName: ["Some Product Line", "Some Other Product Line"]
|
|
58
66
|
}]
|
|
59
67
|
}],
|
|
60
68
|
groups: [{
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
// ensure migration works
|
|
70
|
+
"some-product-line-id": [{
|
|
71
|
+
displayName: ["Some Product Line", "Some Other Product Line"]
|
|
63
72
|
}]
|
|
64
73
|
}],
|
|
65
74
|
items: [{
|
|
@@ -75,8 +84,10 @@ var branchSchemaFuzzerConfig = [{
|
|
|
75
84
|
freeTrial: [[[0, 1, -3, 100, 0.333, Infinity], ["day", "week", "month", "year"]]],
|
|
76
85
|
serverOnly: [true, false],
|
|
77
86
|
stackable: [true, false],
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
productLineId: ["some-product-line-id", "some-other-product-line-id"],
|
|
88
|
+
catalogId: ["some-product-line-id", "some-other-product-line-id"],
|
|
89
|
+
// ensure migration works
|
|
90
|
+
groupId: ["some-product-line-id", "some-other-product-line-id"],
|
|
80
91
|
// ensure migration works
|
|
81
92
|
isAddOnTo: [false, { "some-product-id": [true], "some-other-product-id": [true] }],
|
|
82
93
|
prices: ["include-by-default", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/schema-fuzzer.test.ts"],"sourcesContent":["import { ALL_APPS } from \"../apps/apps-config\";\nimport { SUPPORTED_CURRENCIES } from \"../utils/currency-constants\";\nimport { StackAssertionError } from \"../utils/errors\";\nimport { getOrUndefined, isObjectLike, set, typedEntries, typedFromEntries } from \"../utils/objects\";\nimport { nicify } from \"../utils/strings\";\nimport { normalize, override } from \"./format\";\nimport { BranchConfigNormalizedOverride, EnvironmentConfigNormalizedOverride, OrganizationConfigNormalizedOverride, ProjectConfigNormalizedOverride, applyBranchDefaults, applyEnvironmentDefaults, applyOrganizationDefaults, applyProjectDefaults, assertNoConfigOverrideErrors, branchConfigSchema, environmentConfigSchema, migrateConfigOverride, organizationConfigSchema, projectConfigSchema, sanitizeBranchConfig, sanitizeEnvironmentConfig, sanitizeOrganizationConfig, sanitizeProjectConfig } from \"./schema\";\n\ntype FuzzerConfig<T> = ReadonlyArray<T extends object ? ([T] extends [any[]] ? { readonly [K in keyof T]: FuzzerConfig<T[K]> } : Required<{\n [K in keyof T]: FuzzerConfig<T[K]>;\n}> & Record<string, FuzzerConfig<any>>) : T>;\n\nconst projectSchemaFuzzerConfig = [{\n sourceOfTruth: [{\n type: [\"hosted\", \"neon\", \"postgres\"],\n connectionString: [\"\", \"postgres://user:password@host:port/database\", \"THIS IS A STRING LOLOL\"],\n connectionStrings: [{\n \"123-some-branch-id\": [\"\", \"THIS IS A CONNECTION STRING OR SO\"],\n }],\n }],\n}] satisfies FuzzerConfig<ProjectConfigNormalizedOverride>;\n\nconst branchSchemaFuzzerConfig = [{\n apiKeys: [{\n enabled: [{\n team: [true, false],\n user: [true, false],\n }],\n }],\n auth: [{\n allowSignUp: [true, false],\n password: [{\n allowSignIn: [true, false],\n }],\n otp: [{\n allowSignIn: [true, false],\n }],\n passkey: [{\n allowSignIn: [true, false],\n }],\n oauth: [{\n accountMergeStrategy: [\"link_method\", \"raise_error\", \"allow_duplicates\"],\n providers: [{\n \"google\": [{\n type: [\"google\", \"github\", \"x\"] as const,\n allowSignIn: [true, false],\n allowConnectedAccounts: [true, false],\n }],\n }],\n }],\n }],\n dataVault: [{\n stores: [{\n \"some-store-id\": [{\n displayName: [\"Some Store\", \"Some Other Store\"],\n }],\n \"some-other-store-id\": [{\n displayName: [\"Some Store\", \"Some Other Store\"],\n }],\n }],\n }],\n payments: [{\n testMode: [false, true],\n autoPay: [{\n interval: [[[0, 1, -3, 100, 0.333, Infinity], [\"day\", \"week\", \"month\", \"year\"]]] as const,\n }],\n catalogs: [{\n \"some-catalog-id\": [{\n displayName: [\"Some Catalog\", \"Some Other Catalog\"],\n }],\n }],\n groups: [{\n \"some-catalog-id\": [{\n displayName: [\"Some Catalog\", \"Some Other Catalog\"],\n }],\n }],\n items: [{\n \"some-item-id\": [{\n customerType: [\"user\", \"team\", \"custom\"] as const,\n displayName: [\"Some Item\", \"Some Other Item\"],\n }],\n }],\n products: [{\n \"some-product-id\": [{\n displayName: [\"Some Product\", \"Some Other Product\"],\n customerType: [\"user\", \"team\", \"custom\"] as const,\n freeTrial: [[[0, 1, -3, 100, 0.333, Infinity], [\"day\", \"week\", \"month\", \"year\"]]] as const,\n serverOnly: [true, false],\n stackable: [true, false],\n catalogId: [\"some-catalog-id\", \"some-other-catalog-id\"],\n groupId: [\"some-catalog-id\", \"some-other-catalog-id\"], // ensure migration works\n isAddOnTo: [false, { \"some-product-id\": [true], \"some-other-product-id\": [true] }] as const,\n prices: [\"include-by-default\" as \"include-by-default\", {\n \"some-price-id\": [{\n ...typedFromEntries(SUPPORTED_CURRENCIES.map(currency => [currency.code, [\"100_00\", \"not a number\", \"Infinity\", \"0\"]])),\n interval: [[[0, 1, -3, 100, 0.333, Infinity], [\"day\", \"week\", \"month\", \"year\"]]] as const,\n serverOnly: [true, false],\n freeTrial: [[[0, 1, -3, 100, 0.333, Infinity], [\"day\", \"week\", \"month\", \"year\"]]] as const,\n }],\n }],\n includedItems: [{\n \"some-item-id\": [{\n quantity: [0, 1, -3, 100, 0.333, Infinity],\n repeat: [\"never\", [[0, 1, -3, 100, 0.333, Infinity], [\"day\", \"week\", \"month\", \"year\"]]] as const,\n expires: [\"never\", \"when-purchase-expires\", \"when-repeated\"] as const,\n }],\n }],\n }],\n }],\n }],\n emails: [{\n themes: [{\n \"12345678-1234-4234-9234-123456789012\": [{\n displayName: [\"Some Theme\", \"Some Other Theme\"],\n tsxSource: [\"\", \"some typescript source code\"],\n }],\n }],\n selectedThemeId: [\"some-theme-id\", \"some-other-theme-id\"],\n templates: [{\n \"12345678-1234-4234-9234-123456789012\": [{\n themeId: [\"some-theme-id\", \"some-other-theme-id\"],\n displayName: [\"Some Template\", \"Some Other Template\"],\n tsxSource: [\"\", \"some typescript source code\"],\n }],\n }],\n }],\n teams: [{\n createPersonalTeamOnSignUp: [true, false],\n allowClientTeamCreation: [true, false],\n }],\n users: [{\n allowClientUserDeletion: [true, false],\n }],\n rbac: [{\n permissions: [{\n \"some_permission_id\": [{\n containedPermissionIds: [{\n \"some_permission_id\": [true],\n \"$some_other_permission_id\": [true],\n }] as const,\n description: [\"Some Permission\", \"Some Other Permission\"],\n scope: [\"team\", \"project\"] as const,\n }],\n }],\n defaultPermissions: [{\n teamCreator: [{\n \"some_permission_id\": [true],\n \"$some_other_permission_id\": [true],\n }] as const,\n teamMember: [{\n \"some_permission_id\": [true],\n \"$some_other_permission_id\": [true],\n }] as const,\n signUp: [{\n \"some_permission_id\": [true],\n \"$some_other_permission_id\": [true],\n }] as const,\n }],\n }],\n domains: [{\n allowLocalhost: [true, false],\n }],\n apps: [{\n installed: [typedFromEntries(typedEntries(ALL_APPS).map(([key, value]) => [key, [{\n enabled: [true, false],\n }]]))],\n }],\n onboarding: [{\n requireEmailVerification: [true, false],\n }],\n}] satisfies FuzzerConfig<BranchConfigNormalizedOverride>;\n\nconst environmentSchemaFuzzerConfig = [{\n ...branchSchemaFuzzerConfig[0],\n auth: [{\n ...branchSchemaFuzzerConfig[0].auth[0],\n oauth: [{\n ...branchSchemaFuzzerConfig[0].auth[0].oauth[0],\n providers: [typedFromEntries(typedEntries(branchSchemaFuzzerConfig[0].auth[0].oauth[0].providers[0]).map(([key, value]) => [key, [{\n ...value[0],\n isShared: [true, false],\n clientId: [\"some-client-id\"],\n clientSecret: [\"some-client-secret\"],\n facebookConfigId: [\"some-facebook-config-id\"],\n microsoftTenantId: [\"some-microsoft-tenant-id\"],\n }]]))] as const,\n }],\n }],\n domains: [{\n ...branchSchemaFuzzerConfig[0].domains[0],\n trustedDomains: [{\n \"some-domain-id\": [{\n baseUrl: [\"https://example.com/something-here\"],\n handlerPath: [\"/something-here\"],\n }],\n }],\n }],\n emails: [{\n ...branchSchemaFuzzerConfig[0].emails[0],\n server: [{\n isShared: [true, false],\n provider: [\"resend\", \"smtp\"] as const,\n host: [\"example.com\", \"://super weird host that's not valid\"],\n port: [1234, 0.12543, -100, Infinity],\n username: [\"some-username\", \"some username with a space\"],\n password: [\"some-password\", \"some password with a space\"],\n senderName: [\"Some Sender\"],\n senderEmail: [\"some-sender@example.com\", \"some invalid email\"],\n }],\n }],\n}] satisfies FuzzerConfig<EnvironmentConfigNormalizedOverride>;\n\nconst organizationSchemaFuzzerConfig = environmentSchemaFuzzerConfig satisfies FuzzerConfig<OrganizationConfigNormalizedOverride>;\n\nfunction setDeep<T>(obj: T, path: string[], value: any) {\n if (!isObjectLike(obj)) return obj;\n\n if (path.length === 0) {\n throw new Error(\"Path is empty\");\n } else if (path.length === 1) {\n set(obj as any, path[0], value);\n } else {\n const [key, ...rest] = path;\n setDeep(getOrUndefined(obj as any, key), rest, value);\n }\n}\n\nfunction createFuzzerInput<T>(config: FuzzerConfig<T>, progress: number): T {\n progress = Math.min(1, 2 * progress);\n const createShouldRandom = (strength: number) => {\n const chance = Math.random() * strength * 1.2 - 0.1;\n return () => Math.random() < chance;\n };\n const createShouldObjectDependent = (strength: number) => {\n const objectChance = Math.random() * strength * 1.2 - 0.1;\n const primitiveChance = Math.random() * strength * 1.2 - 0.1;\n return (v: any) => Math.random() * Math.random() < (isObjectLike(v) ? objectChance : primitiveChance);\n };\n\n const shouldKeep = createShouldObjectDependent(progress * 1);\n const shouldMakeNested = createShouldObjectDependent(1.25);\n const shouldNull = createShouldRandom(0.25);\n\n let res: any;\n const recurse = <U>(outputPath: string[], config: FuzzerConfig<U>, forceNested: boolean, forceNonNull: boolean) => {\n let subConfig: any = config[Math.floor(Math.random() * config.length)];\n const originalValue = isObjectLike(subConfig) ? (Array.isArray(subConfig) ? [] : {}) : subConfig;\n\n const newValue = forceNonNull || !shouldNull() ? originalValue : null;\n const newOutputPath = forceNested || shouldMakeNested(originalValue) || outputPath.length === 0 ? outputPath : [outputPath.join(\".\")];\n if (outputPath.length === 0) {\n res = newValue;\n } else {\n if (forceNested || shouldKeep(originalValue)) {\n setDeep(res, newOutputPath, newValue);\n }\n }\n if (isObjectLike(subConfig)) {\n for (const [key, newValue] of typedEntries(subConfig)) {\n recurse([...newOutputPath, key], newValue, Array.isArray(subConfig), Array.isArray(subConfig));\n }\n }\n };\n recurse<T>([], config, false, true);\n return res;\n}\n\nundefined?.test(\"fuzz schemas\", async ({ expect }) => {\n const totalIterations = process.env.CI ? 1000 : 200;\n for (let i = 0; i < totalIterations; i++) {\n const projectInput = createFuzzerInput<ProjectConfigNormalizedOverride>(projectSchemaFuzzerConfig, i / totalIterations);\n const branchInput = createFuzzerInput<BranchConfigNormalizedOverride>(branchSchemaFuzzerConfig, i / totalIterations);\n const environmentInput = createFuzzerInput<EnvironmentConfigNormalizedOverride>(environmentSchemaFuzzerConfig, i / totalIterations);\n const organizationInput = createFuzzerInput<OrganizationConfigNormalizedOverride>(organizationSchemaFuzzerConfig, i / totalIterations);\n\n try {\n const projectMigrated = migrateConfigOverride(\"project\", projectInput);\n await assertNoConfigOverrideErrors(projectConfigSchema, projectMigrated);\n const projectOverridden = override({}, projectMigrated);\n await sanitizeProjectConfig(normalize(applyProjectDefaults(projectOverridden), { onDotIntoNonObject: \"ignore\" }) as any);\n\n const branchMigrated = migrateConfigOverride(\"branch\", branchInput);\n await assertNoConfigOverrideErrors(branchConfigSchema, branchMigrated);\n const branchOverridden = override(projectOverridden, branchMigrated);\n await sanitizeBranchConfig(normalize(applyBranchDefaults(branchOverridden), { onDotIntoNonObject: \"ignore\" }) as any);\n\n const environmentMigrated = migrateConfigOverride(\"environment\", environmentInput);\n await assertNoConfigOverrideErrors(environmentConfigSchema, environmentMigrated);\n const environmentOverridden = override(branchOverridden, environmentMigrated);\n await sanitizeEnvironmentConfig(normalize(applyEnvironmentDefaults(environmentOverridden), { onDotIntoNonObject: \"ignore\" }) as any);\n\n const organizationMigrated = migrateConfigOverride(\"organization\", organizationInput);\n await assertNoConfigOverrideErrors(organizationConfigSchema, organizationMigrated);\n const organizationOverridden = override(environmentOverridden, organizationMigrated);\n await sanitizeOrganizationConfig(normalize(applyOrganizationDefaults(organizationOverridden), { onDotIntoNonObject: \"ignore\" }) as any);\n\n } catch (e) {\n const data = {\n cause: e,\n inputs: {\n projectInput,\n branchInput,\n environmentInput,\n organizationInput,\n },\n } as const;\n console.error(\"Failed to fuzz schema in iteration ${i}/${totalIterations}!\", nicify(data));\n throw new StackAssertionError(`Error in iteration ${i}/${totalIterations} of schema fuzz: ${e}`, { cause: e });\n }\n }\n});\n"],"mappings":";;;AAAA,yBAAyB;AACzB,gCAAqC;AACrC,oBAAoC;AACpC,qBAAkF;AAClF,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,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/config/schema-fuzzer.test.ts"],"sourcesContent":["import { ALL_APPS } from \"../apps/apps-config\";\nimport { SUPPORTED_CURRENCIES } from \"../utils/currency-constants\";\nimport { StackAssertionError } from \"../utils/errors\";\nimport { getOrUndefined, isObjectLike, set, typedEntries, typedFromEntries } from \"../utils/objects\";\nimport { nicify } from \"../utils/strings\";\nimport { normalize, override } from \"./format\";\nimport { BranchConfigNormalizedOverride, EnvironmentConfigNormalizedOverride, OrganizationConfigNormalizedOverride, ProjectConfigNormalizedOverride, applyBranchDefaults, applyEnvironmentDefaults, applyOrganizationDefaults, applyProjectDefaults, assertNoConfigOverrideErrors, branchConfigSchema, environmentConfigSchema, migrateConfigOverride, organizationConfigSchema, projectConfigSchema, sanitizeBranchConfig, sanitizeEnvironmentConfig, sanitizeOrganizationConfig, sanitizeProjectConfig } from \"./schema\";\n\ntype FuzzerConfig<T> = ReadonlyArray<T extends object ? ([T] extends [any[]] ? { readonly [K in keyof T]: FuzzerConfig<T[K]> } : Required<{\n [K in keyof T]: FuzzerConfig<T[K]>;\n}> & Record<string, FuzzerConfig<any>>) : T>;\n\nconst projectSchemaFuzzerConfig = [{\n sourceOfTruth: [{\n type: [\"hosted\", \"neon\", \"postgres\"],\n connectionString: [\"\", \"postgres://user:password@host:port/database\", \"THIS IS A STRING LOLOL\"],\n connectionStrings: [{\n \"123-some-branch-id\": [\"\", \"THIS IS A CONNECTION STRING OR SO\"],\n }],\n }],\n}] satisfies FuzzerConfig<ProjectConfigNormalizedOverride>;\n\nconst branchSchemaFuzzerConfig = [{\n apiKeys: [{\n enabled: [{\n team: [true, false],\n user: [true, false],\n }],\n }],\n auth: [{\n allowSignUp: [true, false],\n password: [{\n allowSignIn: [true, false],\n }],\n otp: [{\n allowSignIn: [true, false],\n }],\n passkey: [{\n allowSignIn: [true, false],\n }],\n oauth: [{\n accountMergeStrategy: [\"link_method\", \"raise_error\", \"allow_duplicates\"],\n providers: [{\n \"google\": [{\n type: [\"google\", \"github\", \"x\"] as const,\n allowSignIn: [true, false],\n allowConnectedAccounts: [true, false],\n }],\n }],\n }],\n }],\n dataVault: [{\n stores: [{\n \"some-store-id\": [{\n displayName: [\"Some Store\", \"Some Other Store\"],\n }],\n \"some-other-store-id\": [{\n displayName: [\"Some Store\", \"Some Other Store\"],\n }],\n }],\n }],\n payments: [{\n blockNewPurchases: [false, true],\n testMode: [false, true],\n autoPay: [{\n interval: [[[0, 1, -3, 100, 0.333, Infinity], [\"day\", \"week\", \"month\", \"year\"]]] as const,\n }],\n productLines: [{\n \"some-product-line-id\": [{\n displayName: [\"Some Product Line\", \"Some Other Product Line\"],\n customerType: [\"user\", \"team\", \"custom\"] as const,\n }],\n }],\n catalogs: [{ // ensure migration works\n \"some-product-line-id\": [{\n displayName: [\"Some Product Line\", \"Some Other Product Line\"],\n }],\n }],\n groups: [{ // ensure migration works\n \"some-product-line-id\": [{\n displayName: [\"Some Product Line\", \"Some Other Product Line\"],\n }],\n }],\n items: [{\n \"some-item-id\": [{\n customerType: [\"user\", \"team\", \"custom\"] as const,\n displayName: [\"Some Item\", \"Some Other Item\"],\n }],\n }],\n products: [{\n \"some-product-id\": [{\n displayName: [\"Some Product\", \"Some Other Product\"],\n customerType: [\"user\", \"team\", \"custom\"] as const,\n freeTrial: [[[0, 1, -3, 100, 0.333, Infinity], [\"day\", \"week\", \"month\", \"year\"]]] as const,\n serverOnly: [true, false],\n stackable: [true, false],\n productLineId: [\"some-product-line-id\", \"some-other-product-line-id\"],\n catalogId: [\"some-product-line-id\", \"some-other-product-line-id\"], // ensure migration works\n groupId: [\"some-product-line-id\", \"some-other-product-line-id\"], // ensure migration works\n isAddOnTo: [false, { \"some-product-id\": [true], \"some-other-product-id\": [true] }] as const,\n prices: [\"include-by-default\" as \"include-by-default\", {\n \"some-price-id\": [{\n ...typedFromEntries(SUPPORTED_CURRENCIES.map(currency => [currency.code, [\"100_00\", \"not a number\", \"Infinity\", \"0\"]])),\n interval: [[[0, 1, -3, 100, 0.333, Infinity], [\"day\", \"week\", \"month\", \"year\"]]] as const,\n serverOnly: [true, false],\n freeTrial: [[[0, 1, -3, 100, 0.333, Infinity], [\"day\", \"week\", \"month\", \"year\"]]] as const,\n }],\n }],\n includedItems: [{\n \"some-item-id\": [{\n quantity: [0, 1, -3, 100, 0.333, Infinity],\n repeat: [\"never\", [[0, 1, -3, 100, 0.333, Infinity], [\"day\", \"week\", \"month\", \"year\"]]] as const,\n expires: [\"never\", \"when-purchase-expires\", \"when-repeated\"] as const,\n }],\n }],\n }],\n }],\n }],\n emails: [{\n themes: [{\n \"12345678-1234-4234-9234-123456789012\": [{\n displayName: [\"Some Theme\", \"Some Other Theme\"],\n tsxSource: [\"\", \"some typescript source code\"],\n }],\n }],\n selectedThemeId: [\"some-theme-id\", \"some-other-theme-id\"],\n templates: [{\n \"12345678-1234-4234-9234-123456789012\": [{\n themeId: [\"some-theme-id\", \"some-other-theme-id\"],\n displayName: [\"Some Template\", \"Some Other Template\"],\n tsxSource: [\"\", \"some typescript source code\"],\n }],\n }],\n }],\n teams: [{\n createPersonalTeamOnSignUp: [true, false],\n allowClientTeamCreation: [true, false],\n }],\n users: [{\n allowClientUserDeletion: [true, false],\n }],\n rbac: [{\n permissions: [{\n \"some_permission_id\": [{\n containedPermissionIds: [{\n \"some_permission_id\": [true],\n \"$some_other_permission_id\": [true],\n }] as const,\n description: [\"Some Permission\", \"Some Other Permission\"],\n scope: [\"team\", \"project\"] as const,\n }],\n }],\n defaultPermissions: [{\n teamCreator: [{\n \"some_permission_id\": [true],\n \"$some_other_permission_id\": [true],\n }] as const,\n teamMember: [{\n \"some_permission_id\": [true],\n \"$some_other_permission_id\": [true],\n }] as const,\n signUp: [{\n \"some_permission_id\": [true],\n \"$some_other_permission_id\": [true],\n }] as const,\n }],\n }],\n domains: [{\n allowLocalhost: [true, false],\n }],\n apps: [{\n installed: [typedFromEntries(typedEntries(ALL_APPS).map(([key, value]) => [key, [{\n enabled: [true, false],\n }]]))],\n }],\n onboarding: [{\n requireEmailVerification: [true, false],\n }],\n}] satisfies FuzzerConfig<BranchConfigNormalizedOverride>;\n\nconst environmentSchemaFuzzerConfig = [{\n ...branchSchemaFuzzerConfig[0],\n auth: [{\n ...branchSchemaFuzzerConfig[0].auth[0],\n oauth: [{\n ...branchSchemaFuzzerConfig[0].auth[0].oauth[0],\n providers: [typedFromEntries(typedEntries(branchSchemaFuzzerConfig[0].auth[0].oauth[0].providers[0]).map(([key, value]) => [key, [{\n ...value[0],\n isShared: [true, false],\n clientId: [\"some-client-id\"],\n clientSecret: [\"some-client-secret\"],\n facebookConfigId: [\"some-facebook-config-id\"],\n microsoftTenantId: [\"some-microsoft-tenant-id\"],\n }]]))] as const,\n }],\n }],\n domains: [{\n ...branchSchemaFuzzerConfig[0].domains[0],\n trustedDomains: [{\n \"some-domain-id\": [{\n baseUrl: [\"https://example.com/something-here\"],\n handlerPath: [\"/something-here\"],\n }],\n }],\n }],\n emails: [{\n ...branchSchemaFuzzerConfig[0].emails[0],\n server: [{\n isShared: [true, false],\n provider: [\"resend\", \"smtp\"] as const,\n host: [\"example.com\", \"://super weird host that's not valid\"],\n port: [1234, 0.12543, -100, Infinity],\n username: [\"some-username\", \"some username with a space\"],\n password: [\"some-password\", \"some password with a space\"],\n senderName: [\"Some Sender\"],\n senderEmail: [\"some-sender@example.com\", \"some invalid email\"],\n }],\n }],\n}] satisfies FuzzerConfig<EnvironmentConfigNormalizedOverride>;\n\nconst organizationSchemaFuzzerConfig = environmentSchemaFuzzerConfig satisfies FuzzerConfig<OrganizationConfigNormalizedOverride>;\n\nfunction setDeep<T>(obj: T, path: string[], value: any) {\n if (!isObjectLike(obj)) return obj;\n\n if (path.length === 0) {\n throw new Error(\"Path is empty\");\n } else if (path.length === 1) {\n set(obj as any, path[0], value);\n } else {\n const [key, ...rest] = path;\n setDeep(getOrUndefined(obj as any, key), rest, value);\n }\n}\n\nfunction createFuzzerInput<T>(config: FuzzerConfig<T>, progress: number): T {\n progress = Math.min(1, 2 * progress);\n const createShouldRandom = (strength: number) => {\n const chance = Math.random() * strength * 1.2 - 0.1;\n return () => Math.random() < chance;\n };\n const createShouldObjectDependent = (strength: number) => {\n const objectChance = Math.random() * strength * 1.2 - 0.1;\n const primitiveChance = Math.random() * strength * 1.2 - 0.1;\n return (v: any) => Math.random() * Math.random() < (isObjectLike(v) ? objectChance : primitiveChance);\n };\n\n const shouldKeep = createShouldObjectDependent(progress * 1);\n const shouldMakeNested = createShouldObjectDependent(1.25);\n const shouldNull = createShouldRandom(0.25);\n\n let res: any;\n const recurse = <U>(outputPath: string[], config: FuzzerConfig<U>, forceNested: boolean, forceNonNull: boolean) => {\n let subConfig: any = config[Math.floor(Math.random() * config.length)];\n const originalValue = isObjectLike(subConfig) ? (Array.isArray(subConfig) ? [] : {}) : subConfig;\n\n const newValue = forceNonNull || !shouldNull() ? originalValue : null;\n const newOutputPath = forceNested || shouldMakeNested(originalValue) || outputPath.length === 0 ? outputPath : [outputPath.join(\".\")];\n if (outputPath.length === 0) {\n res = newValue;\n } else {\n if (forceNested || shouldKeep(originalValue)) {\n setDeep(res, newOutputPath, newValue);\n }\n }\n if (isObjectLike(subConfig)) {\n for (const [key, newValue] of typedEntries(subConfig)) {\n recurse([...newOutputPath, key], newValue, Array.isArray(subConfig), Array.isArray(subConfig));\n }\n }\n };\n recurse<T>([], config, false, true);\n return res;\n}\n\nundefined?.test(\"fuzz schemas\", async ({ expect }) => {\n const totalIterations = process.env.CI ? 1000 : 200;\n for (let i = 0; i < totalIterations; i++) {\n const projectInput = createFuzzerInput<ProjectConfigNormalizedOverride>(projectSchemaFuzzerConfig, i / totalIterations);\n const branchInput = createFuzzerInput<BranchConfigNormalizedOverride>(branchSchemaFuzzerConfig, i / totalIterations);\n const environmentInput = createFuzzerInput<EnvironmentConfigNormalizedOverride>(environmentSchemaFuzzerConfig, i / totalIterations);\n const organizationInput = createFuzzerInput<OrganizationConfigNormalizedOverride>(organizationSchemaFuzzerConfig, i / totalIterations);\n\n try {\n const projectMigrated = migrateConfigOverride(\"project\", projectInput);\n await assertNoConfigOverrideErrors(projectConfigSchema, projectMigrated);\n const projectOverridden = override({}, projectMigrated);\n await sanitizeProjectConfig(normalize(applyProjectDefaults(projectOverridden), { onDotIntoNonObject: \"ignore\" }) as any);\n\n const branchMigrated = migrateConfigOverride(\"branch\", branchInput);\n await assertNoConfigOverrideErrors(branchConfigSchema, branchMigrated);\n const branchOverridden = override(projectOverridden, branchMigrated);\n await sanitizeBranchConfig(normalize(applyBranchDefaults(branchOverridden), { onDotIntoNonObject: \"ignore\" }) as any);\n\n const environmentMigrated = migrateConfigOverride(\"environment\", environmentInput);\n await assertNoConfigOverrideErrors(environmentConfigSchema, environmentMigrated);\n const environmentOverridden = override(branchOverridden, environmentMigrated);\n await sanitizeEnvironmentConfig(normalize(applyEnvironmentDefaults(environmentOverridden), { onDotIntoNonObject: \"ignore\" }) as any);\n\n const organizationMigrated = migrateConfigOverride(\"organization\", organizationInput);\n await assertNoConfigOverrideErrors(organizationConfigSchema, organizationMigrated);\n const organizationOverridden = override(environmentOverridden, organizationMigrated);\n await sanitizeOrganizationConfig(normalize(applyOrganizationDefaults(organizationOverridden), { onDotIntoNonObject: \"ignore\" }) as any);\n\n } catch (e) {\n const data = {\n cause: e,\n inputs: {\n projectInput,\n branchInput,\n environmentInput,\n organizationInput,\n },\n } as const;\n console.error(\"Failed to fuzz schema in iteration ${i}/${totalIterations}!\", nicify(data));\n throw new StackAssertionError(`Error in iteration ${i}/${totalIterations} of schema fuzz: ${e}`, { cause: e });\n }\n }\n});\n"],"mappings":";;;AAAA,yBAAyB;AACzB,gCAAqC;AACrC,oBAAoC;AACpC,qBAAkF;AAClF,qBAAuB;AACvB,oBAAoC;AACpC,oBAAgf;AAgBhf,IAAM,2BAA2B,CAAC;AAAA,EAChC,SAAS,CAAC;AAAA,IACR,SAAS,CAAC;AAAA,MACR,MAAM,CAAC,MAAM,KAAK;AAAA,MAClB,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