@open-mercato/shared 0.9.1-develop.7574.1.837288eec1 → 0.10.1-develop.7576.1.21d5b50435
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/.turbo/turbo-build.log +1 -1
- package/AGENTS.md +4 -4
- package/dist/lib/auth/server.js +1 -1
- package/dist/lib/auth/server.js.map +2 -2
- package/dist/lib/bootstrap/dynamicLoader.js +6 -46
- package/dist/lib/bootstrap/dynamicLoader.js.map +2 -2
- package/dist/lib/bootstrap/factory.js +3 -4
- package/dist/lib/bootstrap/factory.js.map +2 -2
- package/dist/lib/catalog-visibility/index.js +0 -4
- package/dist/lib/catalog-visibility/index.js.map +2 -2
- package/dist/lib/commands/command-bus.js +13 -45
- package/dist/lib/commands/command-bus.js.map +2 -2
- package/dist/lib/commands/types.js.map +2 -2
- package/dist/lib/crud/exporters.js +1 -1
- package/dist/lib/crud/exporters.js.map +2 -2
- package/dist/lib/crud/ids.js +1 -13
- package/dist/lib/crud/ids.js.map +2 -2
- package/dist/lib/db/pg-errors.js +0 -14
- package/dist/lib/db/pg-errors.js.map +2 -2
- package/dist/lib/localization/index.js +1 -9
- package/dist/lib/localization/index.js.map +2 -2
- package/dist/lib/localization/translatable-fields.js +0 -26
- package/dist/lib/localization/translatable-fields.js.map +2 -2
- package/dist/lib/number.js +0 -6
- package/dist/lib/number.js.map +2 -2
- package/dist/lib/openapi/generator.js +67 -84
- package/dist/lib/openapi/generator.js.map +2 -2
- package/dist/lib/query/engine.js +10 -45
- package/dist/lib/query/engine.js.map +2 -2
- package/dist/lib/query/join-utils.js +1 -1
- package/dist/lib/query/join-utils.js.map +2 -2
- package/dist/lib/query/types.js.map +2 -2
- package/dist/lib/url.js +0 -24
- package/dist/lib/url.js.map +2 -2
- package/dist/lib/version.js +1 -1
- package/dist/lib/version.js.map +1 -1
- package/dist/lib/webhooks/body.js +3 -7
- package/dist/lib/webhooks/body.js.map +2 -2
- package/dist/lib/webhooks/index.js +0 -2
- package/dist/lib/webhooks/index.js.map +2 -2
- package/dist/modules/integrations/types.js.map +2 -2
- package/dist/modules/notifications/types.js +0 -4
- package/dist/modules/notifications/types.js.map +3 -3
- package/dist/modules/payment_gateways/types.js +1 -14
- package/dist/modules/payment_gateways/types.js.map +2 -2
- package/dist/modules/registry.js.map +2 -2
- package/dist/modules/search.js.map +2 -2
- package/dist/modules/widgets/injection-loader.js +3 -14
- package/dist/modules/widgets/injection-loader.js.map +2 -2
- package/package.json +3 -10
- package/src/lib/__tests__/number.test.ts +1 -24
- package/src/lib/auth/__tests__/server.test.ts +0 -14
- package/src/lib/auth/server.ts +1 -1
- package/src/lib/bootstrap/__tests__/dynamicLoader.appDi.test.ts +2 -2
- package/src/lib/bootstrap/__tests__/dynamicLoader.appModuleOverrides.test.ts +2 -2
- package/src/lib/bootstrap/__tests__/dynamicLoader.cacheRecovery.test.ts +2 -2
- package/src/lib/bootstrap/__tests__/dynamicLoader.commandInterceptors.test.ts +2 -2
- package/src/lib/bootstrap/__tests__/dynamicLoader.tsconfig.test.ts +2 -2
- package/src/lib/bootstrap/__tests__/factory.test.ts +6 -18
- package/src/lib/bootstrap/dynamicLoader.ts +5 -63
- package/src/lib/bootstrap/factory.ts +3 -8
- package/src/lib/bootstrap/types.ts +1 -5
- package/src/lib/catalog-visibility/index.ts +0 -2
- package/src/lib/commands/__tests__/command-bus.test.ts +1 -100
- package/src/lib/commands/command-bus.ts +10 -42
- package/src/lib/commands/command-interceptor.ts +0 -4
- package/src/lib/commands/types.ts +0 -14
- package/src/lib/crud/__tests__/exporters.test.ts +0 -18
- package/src/lib/crud/__tests__/ids.test.ts +1 -34
- package/src/lib/crud/exporters.ts +1 -1
- package/src/lib/crud/ids.ts +0 -24
- package/src/lib/db/__tests__/pg-errors.test.ts +1 -68
- package/src/lib/db/pg-errors.ts +0 -35
- package/src/lib/encryption/__tests__/tenantDataEncryptionService.test.ts +0 -23
- package/src/lib/localization/__tests__/translatable-fields.test.ts +0 -17
- package/src/lib/localization/index.ts +1 -8
- package/src/lib/localization/translatable-fields.ts +0 -46
- package/src/lib/number.ts +0 -13
- package/src/lib/openapi/generator.ts +77 -106
- package/src/lib/query/engine.ts +8 -58
- package/src/lib/query/join-utils.ts +1 -1
- package/src/lib/query/types.ts +1 -13
- package/src/lib/url.ts +0 -30
- package/src/lib/webhooks/__tests__/body.test.ts +0 -48
- package/src/lib/webhooks/body.ts +4 -11
- package/src/lib/webhooks/index.ts +0 -1
- package/src/modules/integrations/types.ts +0 -6
- package/src/modules/notifications/types.ts +0 -7
- package/src/modules/payment_gateways/__tests__/types.test.ts +0 -44
- package/src/modules/payment_gateways/types.ts +6 -52
- package/src/modules/registry.ts +0 -5
- package/src/modules/search.ts +0 -39
- package/src/modules/widgets/injection-loader.ts +3 -33
- package/dist/lib/bootstrap/next-subpath-resolve-hook-worker.js +0 -6
- package/dist/lib/bootstrap/next-subpath-resolve-hook-worker.js.map +0 -7
- package/dist/lib/bootstrap/next-subpath-resolve-hook.js +0 -62
- package/dist/lib/bootstrap/next-subpath-resolve-hook.js.map +0 -7
- package/dist/lib/catalog-visibility/canonicalizeEffectiveScope.js +0 -33
- package/dist/lib/catalog-visibility/canonicalizeEffectiveScope.js.map +0 -7
- package/dist/lib/catalog-visibility/hashEffectiveScope.js +0 -9
- package/dist/lib/catalog-visibility/hashEffectiveScope.js.map +0 -7
- package/dist/lib/db/advisoryLock.js +0 -172
- package/dist/lib/db/advisoryLock.js.map +0 -7
- package/dist/lib/query/overlap.js +0 -58
- package/dist/lib/query/overlap.js.map +0 -7
- package/dist/modules/notifications/safeHref.js +0 -20
- package/dist/modules/notifications/safeHref.js.map +0 -7
- package/src/lib/__tests__/url.cross-site.test.ts +0 -140
- package/src/lib/bootstrap/__tests__/dynamicLoader.externalSubpath.test.ts +0 -141
- package/src/lib/bootstrap/__tests__/next-subpath-resolve-hook.test.ts +0 -174
- package/src/lib/bootstrap/next-subpath-resolve-hook-worker.ts +0 -3
- package/src/lib/bootstrap/next-subpath-resolve-hook.ts +0 -130
- package/src/lib/catalog-visibility/__tests__/hashEffectiveScope.test.ts +0 -121
- package/src/lib/catalog-visibility/canonicalizeEffectiveScope.ts +0 -41
- package/src/lib/catalog-visibility/hashEffectiveScope.ts +0 -8
- package/src/lib/db/__tests__/advisoryLock.integration.test.ts +0 -343
- package/src/lib/db/__tests__/advisoryLock.test.ts +0 -564
- package/src/lib/db/advisoryLock.ts +0 -271
- package/src/lib/openapi/__tests__/optional-path-params.test.ts +0 -102
- package/src/lib/query/__tests__/empty-ids-filter.pg.test.ts +0 -89
- package/src/lib/query/__tests__/engine.empty-in-filter.test.ts +0 -79
- package/src/lib/query/__tests__/overlap.test.ts +0 -219
- package/src/lib/query/overlap.ts +0 -106
- package/src/modules/notifications/safeHref.ts +0 -19
- package/src/modules/widgets/__tests__/injection-loader.partitioned-registration.test.ts +0 -78
|
@@ -59,19 +59,6 @@ function normalizePath(path) {
|
|
|
59
59
|
}).join("/");
|
|
60
60
|
return { path: "/" + normalized, params };
|
|
61
61
|
}
|
|
62
|
-
function expandOptionalPathParams(normalized) {
|
|
63
|
-
const required = normalized.params.filter((param) => !param.optional);
|
|
64
|
-
const optionalParam = normalized.params.find((param) => param.optional);
|
|
65
|
-
const fullVariant = {
|
|
66
|
-
path: normalized.path,
|
|
67
|
-
params: normalized.params.map((param) => ({ ...param, optional: false }))
|
|
68
|
-
};
|
|
69
|
-
if (!optionalParam) return [fullVariant];
|
|
70
|
-
const placeholder = `/{${optionalParam.name}}`;
|
|
71
|
-
if (!normalized.path.endsWith(placeholder)) return [fullVariant];
|
|
72
|
-
const basePath = normalized.path.slice(0, -placeholder.length) || "/";
|
|
73
|
-
return [fullVariant, { path: basePath, params: required, omittedParam: optionalParam.name }];
|
|
74
|
-
}
|
|
75
62
|
function unwrap(schema) {
|
|
76
63
|
if (!schema) {
|
|
77
64
|
return { schema: void 0, optional: true, nullable: false };
|
|
@@ -577,14 +564,14 @@ function buildParameters(schema, location, pathParamNames) {
|
|
|
577
564
|
const params = [];
|
|
578
565
|
if (location === "path" && pathParamNames && pathParamNames.length) {
|
|
579
566
|
const merged = mergePathParamSchemas(schema, pathParamNames);
|
|
580
|
-
for (const { name, schema: paramSchema } of merged) {
|
|
567
|
+
for (const { name, schema: paramSchema, optional } of merged) {
|
|
581
568
|
const jsonSchema = zodToJsonSchema(paramSchema);
|
|
582
569
|
const example = generateExample(paramSchema);
|
|
583
570
|
const description = extractZodDescription(paramSchema);
|
|
584
571
|
params.push({
|
|
585
572
|
name,
|
|
586
573
|
in: "path",
|
|
587
|
-
required:
|
|
574
|
+
required: !optional,
|
|
588
575
|
schema: jsonSchema ?? { type: "string" },
|
|
589
576
|
example,
|
|
590
577
|
...description ? { description } : {}
|
|
@@ -644,7 +631,8 @@ function mergePathParamSchemas(schema, params) {
|
|
|
644
631
|
for (const param of params) {
|
|
645
632
|
merged.push({
|
|
646
633
|
name: param.name,
|
|
647
|
-
schema: map[param.name]
|
|
634
|
+
schema: map[param.name],
|
|
635
|
+
optional: !!param.optional
|
|
648
636
|
});
|
|
649
637
|
}
|
|
650
638
|
return merged;
|
|
@@ -895,7 +883,6 @@ function buildOpenApiDocument(modules, options = {}) {
|
|
|
895
883
|
ensureSecurityComponents(doc);
|
|
896
884
|
const includeAccessControlMetadata = options.includeAccessControlMetadata !== false;
|
|
897
885
|
const tags = /* @__PURE__ */ new Map();
|
|
898
|
-
const derivedOperations = /* @__PURE__ */ new Set();
|
|
899
886
|
for (const moduleEntry of modules) {
|
|
900
887
|
const defaultTag = moduleEntry.info?.title ?? toTitle(moduleEntry.id);
|
|
901
888
|
if (defaultTag) tags.set(defaultTag, moduleEntry.info?.description);
|
|
@@ -903,75 +890,71 @@ function buildOpenApiDocument(modules, options = {}) {
|
|
|
903
890
|
for (const api of apis) {
|
|
904
891
|
const routeDoc = collectRouteDoc(api, moduleEntry.id);
|
|
905
892
|
const moduleTag = routeDoc?.tag ?? defaultTag;
|
|
893
|
+
const normalized = normalizePath(api.path ?? api.path ?? "");
|
|
894
|
+
const pathKey = normalized.path;
|
|
895
|
+
if (!doc.paths[pathKey]) doc.paths[pathKey] = {};
|
|
906
896
|
const availableMethods = "handlers" in api ? HTTP_METHODS.filter((method) => typeof api.handlers?.[method] === "function") : [api.method];
|
|
907
|
-
for (const
|
|
908
|
-
const
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
if (baseDescription) descriptionParts.push(baseDescription);
|
|
927
|
-
if (includeAccessControlMetadata && Array.isArray(requireFeatures) && requireFeatures.length) {
|
|
928
|
-
descriptionParts.push(`Requires features: ${requireFeatures.join(", ")}`);
|
|
929
|
-
}
|
|
930
|
-
if (includeAccessControlMetadata && Array.isArray(requireRoles) && requireRoles.length) {
|
|
931
|
-
descriptionParts.push(`Requires roles: ${requireRoles.join(", ")}`);
|
|
932
|
-
}
|
|
933
|
-
const querySchema = methodDoc?.query;
|
|
934
|
-
const pathSchema = methodDoc?.pathParams ?? routeDoc?.pathParams;
|
|
935
|
-
const headerSchema = methodDoc?.headers;
|
|
936
|
-
const requestBody = methodDoc?.requestBody;
|
|
937
|
-
const examples = collectExamples(querySchema, requestBody?.schema, pathSchema, headerSchema, metadata);
|
|
938
|
-
const curlSample = buildCurlSample(
|
|
939
|
-
method,
|
|
940
|
-
pathKey,
|
|
941
|
-
normalized.params,
|
|
942
|
-
examples,
|
|
943
|
-
options.baseUrlForExamples ?? "https://api.open-mercato.local",
|
|
944
|
-
metadata,
|
|
945
|
-
requestBody
|
|
946
|
-
);
|
|
947
|
-
doc.paths[pathKey][methodLower] = {
|
|
948
|
-
operationId: methodDoc?.operationId ? normalized.omittedParam ? `${methodDoc.operationId}_without_${normalizeOperationIdSegment(normalized.omittedParam)}` : methodDoc.operationId : resolveOperationId(moduleEntry.id, pathKey, method),
|
|
949
|
-
summary,
|
|
950
|
-
description: descriptionParts.length ? descriptionParts.join("\n\n") : void 0,
|
|
951
|
-
tags: methodDoc?.tags ?? (moduleTag ? [moduleTag] : void 0),
|
|
952
|
-
deprecated: methodDoc?.deprecated,
|
|
953
|
-
externalDocs: methodDoc?.externalDocs,
|
|
954
|
-
parameters: [
|
|
955
|
-
...buildParameters(pathSchema, "path", normalized.params),
|
|
956
|
-
...buildParameters(querySchema, "query"),
|
|
957
|
-
...buildParameters(headerSchema, "header")
|
|
958
|
-
].filter(Boolean),
|
|
959
|
-
requestBody: buildRequestBody(requestBody),
|
|
960
|
-
responses: buildResponses(method, methodDoc?.responses, methodDoc?.errors, metadata),
|
|
961
|
-
security: buildSecurity(metadata, methodDoc, options.defaultSecurity),
|
|
962
|
-
"x-codeSamples": methodDoc?.codeSamples ?? [
|
|
963
|
-
{
|
|
964
|
-
lang: "curl",
|
|
965
|
-
label: "cURL",
|
|
966
|
-
source: curlSample
|
|
967
|
-
}
|
|
968
|
-
],
|
|
969
|
-
...includeAccessControlMetadata && Array.isArray(requireFeatures) && requireFeatures.length ? { "x-require-features": requireFeatures } : {},
|
|
970
|
-
...includeAccessControlMetadata && Array.isArray(requireRoles) && requireRoles.length ? { "x-require-roles": requireRoles } : {},
|
|
971
|
-
...requireAuth ? { "x-require-auth": true } : {},
|
|
972
|
-
...methodDoc?.extensions ?? {}
|
|
973
|
-
};
|
|
897
|
+
for (const method of availableMethods) {
|
|
898
|
+
const methodLower = method.toLowerCase();
|
|
899
|
+
const existing = doc.paths[pathKey][methodLower];
|
|
900
|
+
if (existing) continue;
|
|
901
|
+
const metadata = "handlers" in api ? api.metadata?.[method] : void 0;
|
|
902
|
+
const methodDoc = routeDoc?.methods?.[method];
|
|
903
|
+
const summary = methodDoc?.summary ?? routeDoc?.summary ?? `${method} ${pathKey}`;
|
|
904
|
+
const baseDescription = methodDoc?.description ?? routeDoc?.description;
|
|
905
|
+
const meta = metadata && typeof metadata === "object" ? metadata : void 0;
|
|
906
|
+
const requireFeatures = Array.isArray(meta?.["requireFeatures"]) ? meta["requireFeatures"] : void 0;
|
|
907
|
+
const requireRoles = Array.isArray(meta?.["requireRoles"]) ? meta["requireRoles"] : void 0;
|
|
908
|
+
const requireAuth = meta?.["requireAuth"] === true;
|
|
909
|
+
const descriptionParts = [];
|
|
910
|
+
if (baseDescription) descriptionParts.push(baseDescription);
|
|
911
|
+
if (includeAccessControlMetadata && Array.isArray(requireFeatures) && requireFeatures.length) {
|
|
912
|
+
descriptionParts.push(`Requires features: ${requireFeatures.join(", ")}`);
|
|
913
|
+
}
|
|
914
|
+
if (includeAccessControlMetadata && Array.isArray(requireRoles) && requireRoles.length) {
|
|
915
|
+
descriptionParts.push(`Requires roles: ${requireRoles.join(", ")}`);
|
|
974
916
|
}
|
|
917
|
+
const querySchema = methodDoc?.query;
|
|
918
|
+
const pathSchema = methodDoc?.pathParams ?? routeDoc?.pathParams;
|
|
919
|
+
const headerSchema = methodDoc?.headers;
|
|
920
|
+
const requestBody = methodDoc?.requestBody;
|
|
921
|
+
const examples = collectExamples(querySchema, requestBody?.schema, pathSchema, headerSchema, metadata);
|
|
922
|
+
const curlSample = buildCurlSample(
|
|
923
|
+
method,
|
|
924
|
+
pathKey,
|
|
925
|
+
normalized.params,
|
|
926
|
+
examples,
|
|
927
|
+
options.baseUrlForExamples ?? "https://api.open-mercato.local",
|
|
928
|
+
metadata,
|
|
929
|
+
requestBody
|
|
930
|
+
);
|
|
931
|
+
doc.paths[pathKey][methodLower] = {
|
|
932
|
+
operationId: methodDoc?.operationId ?? resolveOperationId(moduleEntry.id, pathKey, method),
|
|
933
|
+
summary,
|
|
934
|
+
description: descriptionParts.length ? descriptionParts.join("\n\n") : void 0,
|
|
935
|
+
tags: methodDoc?.tags ?? (moduleTag ? [moduleTag] : void 0),
|
|
936
|
+
deprecated: methodDoc?.deprecated,
|
|
937
|
+
externalDocs: methodDoc?.externalDocs,
|
|
938
|
+
parameters: [
|
|
939
|
+
...buildParameters(pathSchema, "path", normalized.params),
|
|
940
|
+
...buildParameters(querySchema, "query"),
|
|
941
|
+
...buildParameters(headerSchema, "header")
|
|
942
|
+
].filter(Boolean),
|
|
943
|
+
requestBody: buildRequestBody(requestBody),
|
|
944
|
+
responses: buildResponses(method, methodDoc?.responses, methodDoc?.errors, metadata),
|
|
945
|
+
security: buildSecurity(metadata, methodDoc, options.defaultSecurity),
|
|
946
|
+
"x-codeSamples": methodDoc?.codeSamples ?? [
|
|
947
|
+
{
|
|
948
|
+
lang: "curl",
|
|
949
|
+
label: "cURL",
|
|
950
|
+
source: curlSample
|
|
951
|
+
}
|
|
952
|
+
],
|
|
953
|
+
...includeAccessControlMetadata && Array.isArray(requireFeatures) && requireFeatures.length ? { "x-require-features": requireFeatures } : {},
|
|
954
|
+
...includeAccessControlMetadata && Array.isArray(requireRoles) && requireRoles.length ? { "x-require-roles": requireRoles } : {},
|
|
955
|
+
...requireAuth ? { "x-require-auth": true } : {},
|
|
956
|
+
...methodDoc?.extensions ?? {}
|
|
957
|
+
};
|
|
975
958
|
}
|
|
976
959
|
}
|
|
977
960
|
}
|