@cmssy/codemod 16.11.1 → 17.0.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/index.js +67 -56
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12,7 +12,6 @@ var RENAMES = {
|
|
|
12
12
|
var SERVER_SYMBOLS = /* @__PURE__ */ new Set([
|
|
13
13
|
"createCmssyPage",
|
|
14
14
|
"createCmssyEditPage",
|
|
15
|
-
"createCmssyNotFound",
|
|
16
15
|
"CmssyLayoutSlot",
|
|
17
16
|
"CmssyLayoutSlotProps",
|
|
18
17
|
"CmssyLayoutSlotRenderProps",
|
|
@@ -20,33 +19,13 @@ var SERVER_SYMBOLS = /* @__PURE__ */ new Set([
|
|
|
20
19
|
"CmssyLayoutResolution",
|
|
21
20
|
"CmssyLayoutEditableProps",
|
|
22
21
|
"ResolveCmssyLayoutOptions",
|
|
23
|
-
"CreateCmssyNotFoundOptions",
|
|
24
|
-
"buildCmssyMetadata",
|
|
25
|
-
"BuildCmssyMetadataOptions",
|
|
26
|
-
"createCmssyRobots",
|
|
27
|
-
"CreateCmssyRobotsOptions",
|
|
28
|
-
"createCmssySitemap",
|
|
29
|
-
"CreateCmssySitemapOptions",
|
|
30
|
-
"CmssySitemapContext",
|
|
31
|
-
"createCmssyAuthRoute",
|
|
32
|
-
"CmssyAuthRouteHandlers",
|
|
33
|
-
"createCmssyCartRoute",
|
|
34
|
-
"CmssyCartRouteHandlers",
|
|
35
|
-
"CMSSY_CART_COOKIE",
|
|
36
|
-
"createCmssyOrdersRoute",
|
|
37
|
-
"CmssyOrdersRouteHandlers",
|
|
38
22
|
"createDraftRoute",
|
|
39
23
|
"CmssyDraftRouteConfig",
|
|
40
24
|
"createCmssyRevalidateRoute",
|
|
41
25
|
"CmssyRevalidateRouteConfig",
|
|
42
26
|
"createCmssyBlockDataRoute",
|
|
43
27
|
"CmssyBlockDataRouteConfig",
|
|
44
|
-
"
|
|
45
|
-
"getCmssyAccessToken",
|
|
46
|
-
"getCmssyLocale",
|
|
47
|
-
"isCmssyEditMode",
|
|
48
|
-
"fetchProducts",
|
|
49
|
-
"fetchProduct"
|
|
28
|
+
"isCmssyEditMode"
|
|
50
29
|
]);
|
|
51
30
|
var MIDDLEWARE_SYMBOLS = /* @__PURE__ */ new Set([
|
|
52
31
|
"createCmssyProxy",
|
|
@@ -56,56 +35,80 @@ var MIDDLEWARE_SYMBOLS = /* @__PURE__ */ new Set([
|
|
|
56
35
|
"cmssyEditRewrite",
|
|
57
36
|
"createCmssyEditMiddleware",
|
|
58
37
|
"CMSSY_EDIT_PATH_PREFIX",
|
|
59
|
-
"createCmssyLocaleMiddleware",
|
|
60
|
-
"resolveLocaleFromPathname",
|
|
61
|
-
"createCmssyAuthMiddleware",
|
|
62
|
-
"CmssyAuthMiddleware",
|
|
63
38
|
"isCmssyEditRequest",
|
|
64
39
|
"applyCmssyCsp",
|
|
65
|
-
"
|
|
66
|
-
"CmssyCspOptions",
|
|
67
|
-
"localeForPathname"
|
|
68
|
-
]);
|
|
69
|
-
var CLIENT_SYMBOLS = /* @__PURE__ */ new Set([
|
|
70
|
-
"CmssyLink",
|
|
71
|
-
"CmssyLinkProps",
|
|
72
|
-
"CmssyLocaleProvider",
|
|
73
|
-
"CmssyLocaleProviderProps",
|
|
74
|
-
"useCmssyLocale"
|
|
40
|
+
"CmssyCspOptions"
|
|
75
41
|
]);
|
|
76
42
|
var CORE_SYMBOLS = /* @__PURE__ */ new Set([
|
|
77
|
-
"resolveApiUrl",
|
|
78
43
|
"DEFAULT_CMSSY_API_URL",
|
|
79
44
|
"evaluateFieldConditionGroup",
|
|
80
45
|
"FieldCondition",
|
|
81
46
|
"FieldConditionGroup",
|
|
82
47
|
"FieldConditionLogic",
|
|
83
|
-
"splitCmssyLocale",
|
|
84
|
-
"sealSession",
|
|
85
|
-
"openSession",
|
|
86
|
-
"isAccessExpired",
|
|
87
|
-
"sessionCookieOptions",
|
|
88
|
-
"SESSION_MAX_AGE_SECONDS",
|
|
89
|
-
"CmssySessionPayload",
|
|
90
|
-
"CmssySessionUser",
|
|
91
|
-
"SessionCookieOptions",
|
|
92
48
|
"verifyCmssyWebhook",
|
|
93
49
|
"CmssyWebhookError",
|
|
94
50
|
"CmssyWebhookEvent",
|
|
95
51
|
"CmssyWebhookOrder",
|
|
96
|
-
"VerifyCmssyWebhookOptions"
|
|
97
|
-
"fetchOrderByToken",
|
|
98
|
-
"FetchOrderByTokenOptions",
|
|
99
|
-
"MyOrdersResult",
|
|
100
|
-
"FetchProductsOptions",
|
|
101
|
-
"FetchProductOptions",
|
|
102
|
-
"CmssyProductPage",
|
|
103
|
-
"CmssyStockState"
|
|
52
|
+
"VerifyCmssyWebhookOptions"
|
|
104
53
|
]);
|
|
54
|
+
var OWN_SESSION = "your own session, plus the delivery API's member mutations";
|
|
55
|
+
var OWN_ACTIONS = "your Server Actions over the cart and order mutations";
|
|
56
|
+
var CORE_INTERNAL = "no public replacement - @cmssy/core/internal has it, and internal changes without a major";
|
|
57
|
+
var REACT_INTERNAL = "no public replacement - @cmssy/react/internal has it (@cmssy/remix for React Router), and internal changes without a major";
|
|
58
|
+
var RETIRED_SYMBOLS = {
|
|
59
|
+
buildCmssyMetadata: "your generateMetadata, querying public.page.get",
|
|
60
|
+
BuildCmssyMetadataOptions: "your generateMetadata, querying public.page.get",
|
|
61
|
+
createCmssySitemap: "your app/sitemap.ts, querying public.page.list",
|
|
62
|
+
CreateCmssySitemapOptions: "your app/sitemap.ts, querying public.page.list",
|
|
63
|
+
CmssySitemapContext: "your app/sitemap.ts, querying public.page.list",
|
|
64
|
+
createCmssyRobots: "your app/robots.ts",
|
|
65
|
+
CreateCmssyRobotsOptions: "your app/robots.ts",
|
|
66
|
+
createCmssyNotFound: "your app/not-found.tsx",
|
|
67
|
+
CreateCmssyNotFoundOptions: "your app/not-found.tsx",
|
|
68
|
+
CmssyLink: "next/link plus localizeHref(href, locale)",
|
|
69
|
+
CmssyLinkProps: "next/link plus localizeHref(href, locale)",
|
|
70
|
+
getCmssyLocale: "the routed path, or CMSSY_LOCALE_HEADER",
|
|
71
|
+
getCmssyUser: OWN_SESSION,
|
|
72
|
+
getCmssyAccessToken: OWN_SESSION,
|
|
73
|
+
createCmssyAuthRoute: OWN_SESSION,
|
|
74
|
+
CmssyAuthRouteHandlers: OWN_SESSION,
|
|
75
|
+
createCmssyAuthMiddleware: OWN_SESSION,
|
|
76
|
+
CmssyAuthMiddleware: OWN_SESSION,
|
|
77
|
+
sealSession: OWN_SESSION,
|
|
78
|
+
openSession: OWN_SESSION,
|
|
79
|
+
isAccessExpired: OWN_SESSION,
|
|
80
|
+
sessionCookieOptions: OWN_SESSION,
|
|
81
|
+
SessionCookieOptions: OWN_SESSION,
|
|
82
|
+
SESSION_MAX_AGE_SECONDS: OWN_SESSION,
|
|
83
|
+
CmssySessionPayload: OWN_SESSION,
|
|
84
|
+
CmssySessionUser: OWN_SESSION,
|
|
85
|
+
createCmssyCartRoute: OWN_ACTIONS,
|
|
86
|
+
CmssyCartRouteHandlers: OWN_ACTIONS,
|
|
87
|
+
CMSSY_CART_COOKIE: OWN_ACTIONS,
|
|
88
|
+
createCmssyOrdersRoute: OWN_ACTIONS,
|
|
89
|
+
CmssyOrdersRouteHandlers: OWN_ACTIONS,
|
|
90
|
+
fetchProducts: OWN_ACTIONS,
|
|
91
|
+
fetchProduct: OWN_ACTIONS,
|
|
92
|
+
FetchProductsOptions: OWN_ACTIONS,
|
|
93
|
+
FetchProductOptions: OWN_ACTIONS,
|
|
94
|
+
CmssyProductPage: OWN_ACTIONS,
|
|
95
|
+
CmssyStockState: OWN_ACTIONS,
|
|
96
|
+
fetchOrderByToken: OWN_ACTIONS,
|
|
97
|
+
FetchOrderByTokenOptions: OWN_ACTIONS,
|
|
98
|
+
MyOrdersResult: OWN_ACTIONS,
|
|
99
|
+
createCmssyLocaleMiddleware: "createCmssyProxy - it resolves the language",
|
|
100
|
+
resolveLocaleFromPathname: "createCmssyProxy - it resolves the language",
|
|
101
|
+
cmssyCspHeaders: "applyCmssyCsp from @cmssy/next/middleware",
|
|
102
|
+
resolveApiUrl: CORE_INTERNAL,
|
|
103
|
+
splitCmssyLocale: CORE_INTERNAL,
|
|
104
|
+
localeForPathname: CORE_INTERNAL,
|
|
105
|
+
CmssyLocaleProvider: REACT_INTERNAL,
|
|
106
|
+
CmssyLocaleProviderProps: REACT_INTERNAL,
|
|
107
|
+
useCmssyLocale: REACT_INTERNAL
|
|
108
|
+
};
|
|
105
109
|
var ENTRY_FOR = (symbol) => {
|
|
106
110
|
if (SERVER_SYMBOLS.has(symbol)) return "@cmssy/next/server";
|
|
107
111
|
if (MIDDLEWARE_SYMBOLS.has(symbol)) return "@cmssy/next/middleware";
|
|
108
|
-
if (CLIENT_SYMBOLS.has(symbol)) return "@cmssy/next/client";
|
|
109
112
|
if (CORE_SYMBOLS.has(symbol)) return "@cmssy/core";
|
|
110
113
|
return "@cmssy/next";
|
|
111
114
|
};
|
|
@@ -118,6 +121,7 @@ function parseSpecifiers(body) {
|
|
|
118
121
|
});
|
|
119
122
|
}
|
|
120
123
|
function applyRenames(specifier) {
|
|
124
|
+
if (!Object.hasOwn(RENAMES, specifier.name)) return specifier;
|
|
121
125
|
const replacement = RENAMES[specifier.name];
|
|
122
126
|
if (!replacement) return specifier;
|
|
123
127
|
return {
|
|
@@ -127,11 +131,15 @@ function applyRenames(specifier) {
|
|
|
127
131
|
}
|
|
128
132
|
function transform(source) {
|
|
129
133
|
let changed = false;
|
|
134
|
+
const retired = [];
|
|
130
135
|
let code = source.replace(IMPORT, (match, typeOnly, body) => {
|
|
131
136
|
const specifiers = parseSpecifiers(body).map(applyRenames);
|
|
132
137
|
if (specifiers.length === 0) return match;
|
|
133
138
|
const byEntry = /* @__PURE__ */ new Map();
|
|
134
139
|
for (const specifier of specifiers) {
|
|
140
|
+
if (Object.hasOwn(RETIRED_SYMBOLS, specifier.name) && !retired.includes(specifier.name)) {
|
|
141
|
+
retired.push(specifier.name);
|
|
142
|
+
}
|
|
135
143
|
const entry = ENTRY_FOR(specifier.name);
|
|
136
144
|
const bucket = byEntry.get(entry) ?? [];
|
|
137
145
|
bucket.push(specifier.raw);
|
|
@@ -151,7 +159,10 @@ function transform(source) {
|
|
|
151
159
|
changed = true;
|
|
152
160
|
}
|
|
153
161
|
}
|
|
154
|
-
|
|
162
|
+
const notes = retired.map(
|
|
163
|
+
(symbol) => `${symbol} is gone from the SDK - ${RETIRED_SYMBOLS[symbol] ?? ""}`
|
|
164
|
+
);
|
|
165
|
+
return notes.length > 0 ? { code, changed, notes } : { code, changed };
|
|
155
166
|
}
|
|
156
167
|
|
|
157
168
|
// src/v7.ts
|