ssjs-data 0.3.2 → 0.3.4

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/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "ssjs-data",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Canonical SSJS (Server-Side JavaScript) function catalog, Core library objects, Platform methods, and globals for SFMC tooling",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js",
9
- "./sfmc-globals.d.ts": "./dist/sfmc-globals.d.ts"
9
+ "./urls": "./src/urls.js",
10
+ "./sfmc-globals.d.ts": "./dist/sfmc-globals.d.ts",
11
+ "./site-index.json": "./dist/site-index.json"
10
12
  },
11
13
  "files": [
12
14
  "src",
@@ -34,6 +36,8 @@
34
36
  "scripts": {
35
37
  "test": "echo No tests defined",
36
38
  "generate:dts": "node scripts/generate-dts.mjs",
39
+ "generate:index": "node scripts/generate-site-index.mjs",
40
+ "generate:all": "node scripts/generate-dts.mjs && node scripts/generate-site-index.mjs",
37
41
  "lint": "eslint .",
38
42
  "lint:fix": "eslint --fix .",
39
43
  "prepare": "husky || true",
package/src/index.js CHANGED
@@ -27,7 +27,20 @@ export const SSJS_GLOBALS = [
27
27
  {
28
28
  name: 'Variable',
29
29
  type: 'object',
30
- description: 'Namespace marker — bare-name access to Platform.Variable.* methods.',
30
+ aliasOf: 'Platform.Variable',
31
+ description: 'Bare-name access to Platform.Variable.* methods.',
32
+ },
33
+ {
34
+ name: 'Request',
35
+ type: 'object',
36
+ aliasOf: 'Platform.Request',
37
+ description: 'Bare-name access to Platform.Request.* methods.',
38
+ },
39
+ {
40
+ name: 'Recipient',
41
+ type: 'object',
42
+ aliasOf: 'Platform.Recipient',
43
+ description: 'Bare-name access to Platform.Recipient.* methods.',
31
44
  },
32
45
  {
33
46
  name: 'Attribute',
@@ -200,7 +213,7 @@ export const SSJS_GLOBALS = [
200
213
  aliasOf: 'Platform.Function.IsPhoneNumber',
201
214
  requiresCoreLoad: true,
202
215
  },
203
- { name: 'Write', aliasOf: 'Platform.Response.Write', requiresCoreLoad: true },
216
+ { name: 'Write', aliasOf: 'Platform.Response.Write' },
204
217
  { name: 'Stringify', aliasOf: 'Platform.Function.Stringify', requiresCoreLoad: true },
205
218
  // ── Core-library namespace markers ───────────────────────────────────────
206
219
  {
package/src/urls.js ADDED
@@ -0,0 +1,203 @@
1
+ /**
2
+ * urls.js
3
+ *
4
+ * Single source of truth for all ssjs.guide URL derivation rules.
5
+ *
6
+ * Imported by generate-dts.mjs, generate-site-index.mjs, and any consumer
7
+ * that needs to resolve or validate links to ssjs.guide documentation.
8
+ *
9
+ * All paths are site-relative (starting with /) and include a trailing slash.
10
+ * Prepend GUIDE_BASE_URL to produce fully-qualified links.
11
+ */
12
+
13
+ /** Base URL of the ssjs.guide documentation site. */
14
+ export const GUIDE_BASE_URL = 'https://ssjs.guide';
15
+
16
+ // ── Per-function URL derivation ──────────────────────────────────────────────
17
+ // These functions map a function/method name to its own dedicated page URL.
18
+
19
+ /**
20
+ * URL for a Platform.Function page.
21
+ *
22
+ * @param {string} name - Function name (any case)
23
+ * @returns {string} Site-relative URL
24
+ */
25
+ export const platformFunctionUrl = (name) => `/platform-functions/${name.toLowerCase()}/`;
26
+
27
+ /**
28
+ * URL for an HTTP method page.
29
+ *
30
+ * @param {string} name - Method name (any case)
31
+ * @returns {string} Site-relative URL
32
+ */
33
+ export const httpMethodUrl = (name) => `/http/${name.toLowerCase()}/`;
34
+
35
+ /**
36
+ * Overrides for WSProxy method URLs where the page slug differs from name.toLowerCase().
37
+ * Key: method name in lowercase. Value: site-relative URL.
38
+ *
39
+ * @type {Record<string, string>}
40
+ */
41
+ export const WSPROXY_METHOD_URL_OVERRIDES = {
42
+ // performItem's page is named "perform" (file: perform.md, permalink: /wsproxy/perform/)
43
+ performitem: '/wsproxy/perform/',
44
+ };
45
+
46
+ /**
47
+ * URL for a WSProxy method page.
48
+ * Checks WSPROXY_METHOD_URL_OVERRIDES first, then falls back to /wsproxy/<name.toLowerCase()>/.
49
+ *
50
+ * @param {string} name - Method name (any case)
51
+ * @returns {string} Site-relative URL
52
+ */
53
+ export const wsproxyMethodUrl = (name) => {
54
+ const lower = name.toLowerCase();
55
+ return WSPROXY_METHOD_URL_OVERRIDES[lower] ?? `/wsproxy/${lower}/`;
56
+ };
57
+
58
+ /**
59
+ * URL for a global-function page.
60
+ *
61
+ * @param {string} name - Function name (any case)
62
+ * @returns {string} Site-relative URL
63
+ */
64
+ export const globalFunctionUrl = (name) => `/global-functions/${name.toLowerCase()}/`;
65
+
66
+ // ── Group-page URL maps ──────────────────────────────────────────────────────
67
+ // All methods on a class share one documentation page.
68
+ // Keys use the dot-notation prefix from ssjs-data (e.g. 'Platform.Variable').
69
+
70
+ /**
71
+ * Site-relative URLs for Platform-namespace object pages.
72
+ * Key: dot-notation class prefix used in ssjs-data (e.g. 'Platform.Variable').
73
+ *
74
+ * @type {Record<string, string>}
75
+ */
76
+ export const PLATFORM_OBJECT_URLS = {
77
+ Platform: '/platform-objects/platform-load/',
78
+ 'Platform.Variable': '/platform-objects/platform-variable/',
79
+ 'Platform.Response': '/platform-objects/platform-response/',
80
+ 'Platform.Request': '/platform-objects/platform-request/',
81
+ 'Platform.Recipient': '/platform-objects/platform-recipient/',
82
+ HTTPHeader: '/platform-objects/httpheader/',
83
+ 'DateTime.TimeZone': '/platform-objects/datetime-timezone/',
84
+ ErrorUtil: '/platform-objects/errorutil/',
85
+ };
86
+
87
+ /**
88
+ * Site-relative URLs for Core Library class pages.
89
+ * Key: dot-notation class prefix used in ssjs-data (e.g. 'DataExtension.Fields').
90
+ * Sub-classes that share a parent page point to the same URL.
91
+ *
92
+ * @type {Record<string, string>}
93
+ */
94
+ export const CORE_LIBRARY_URLS = {
95
+ Account: '/core-library/account/',
96
+ 'Account.Tracking': '/core-library/account/',
97
+ AccountUser: '/core-library/accountuser/',
98
+ ContentAreaObj: '/core-library/contentareaobj/',
99
+ DataExtension: '/core-library/dataextension/',
100
+ 'DataExtension.Fields': '/core-library/dataextension-fields/',
101
+ 'DataExtension.Rows': '/core-library/dataextension-rows/',
102
+ DeliveryProfile: '/core-library/deliveryprofile/',
103
+ Email: '/core-library/email/',
104
+ FilterDefinition: '/core-library/filterdefinition/',
105
+ Folder: '/core-library/folder/',
106
+ List: '/core-library/list/',
107
+ 'List.Subscribers': '/core-library/list-subscribers/',
108
+ 'List.Subscribers.Tracking': '/core-library/list-subscribers/',
109
+ Portfolio: '/core-library/portfolio/',
110
+ QueryDefinition: '/core-library/querydefinition/',
111
+ Send: '/core-library/send/',
112
+ 'Send.Definition': '/core-library/senddefinition/',
113
+ 'Send.Tracking': '/core-library/send/',
114
+ SendClassification: '/core-library/sendclassification/',
115
+ SenderProfile: '/core-library/senderprofile/',
116
+ Subscriber: '/core-library/subscriber/',
117
+ 'Subscriber.Attributes': '/core-library/subscriber/',
118
+ 'Subscriber.Lists': '/core-library/subscriber/',
119
+ Template: '/core-library/template/',
120
+ Tracking: '/core-library/events/',
121
+ BounceEvent: '/core-library/events/',
122
+ ClickEvent: '/core-library/events/',
123
+ ForwardedEmailEvent: '/core-library/events/',
124
+ ForwardedEmailOptInEvent: '/core-library/events/',
125
+ NotSentEvent: '/core-library/events/',
126
+ OpenEvent: '/core-library/events/',
127
+ SentEvent: '/core-library/events/',
128
+ SurveyEvent: '/core-library/events/',
129
+ UnsubEvent: '/core-library/events/',
130
+ TriggeredSend: '/core-library/triggeredsend/',
131
+ 'TriggeredSend.Tracking': '/core-library/triggeredsend/',
132
+ 'TriggeredSend.Tracking.Clicks': '/core-library/triggeredsend/',
133
+ 'TriggeredSend.Tracking.TotalByInterval': '/core-library/triggeredsend/',
134
+ };
135
+
136
+ /**
137
+ * Site-relative URLs for ECMAScript built-in section pages.
138
+ * Key: `owner` field value from ECMASCRIPT_BUILTINS entries.
139
+ *
140
+ * @type {Record<string, string>}
141
+ */
142
+ export const ECMASCRIPT_URLS = {
143
+ 'Array.prototype': '/ecmascript-builtins/array-methods/',
144
+ 'String.prototype': '/ecmascript-builtins/string-methods/',
145
+ Math: '/ecmascript-builtins/math/',
146
+ 'Number.prototype': '/ecmascript-builtins/number-methods/',
147
+ 'Object.prototype': '/ecmascript-builtins/object-methods/',
148
+ };
149
+
150
+ /**
151
+ * Standalone URL constants for pages not covered by the function-per-page patterns above.
152
+ *
153
+ * @type {Record<string, string>}
154
+ */
155
+ export const GUIDE_URLS = {
156
+ /** Attribute global-function page (lives under /global-functions/, not /platform-objects/). */
157
+ attribute: '/global-functions/attribute/',
158
+ /** Shared page for all Script.Util.HttpRequest / HttpGet instance methods. */
159
+ httpRequestMethods: '/http/request-methods/',
160
+ /** Script.Util.HttpRequest constructor overview page. */
161
+ scriptUtilHttpRequest: '/http/script-util-httprequest/',
162
+ /** Script.Util.HttpGet constructor overview page. */
163
+ scriptUtilHttpGet: '/http/script-util-httpget/',
164
+ /** WSProxy constructor and overview page. */
165
+ wsproxy: '/wsproxy/',
166
+ };
167
+
168
+ /**
169
+ * Names of SSJS global functions that have a dedicated ssjs.guide page at
170
+ * /global-functions/<name>/. All other globals fall back to the URL of their
171
+ * aliased Platform.Function page.
172
+ *
173
+ * @type {Set.<string>}
174
+ */
175
+ export const GLOBAL_FUNCTION_PAGES = new Set([
176
+ 'write',
177
+ 'stringify',
178
+ 'base64encode',
179
+ 'base64decode',
180
+ 'format',
181
+ 'string',
182
+ 'error',
183
+ 'variable',
184
+ 'attribute',
185
+ ]);
186
+
187
+ /**
188
+ * Platform.Function names (all lowercase) whose ssjs.guide page lives under
189
+ * /global-functions/ rather than /platform-functions/ because the function's
190
+ * primary documentation entry point is the shorter global alias.
191
+ * Use globalFunctionUrl() for these in the site-index.
192
+ *
193
+ * @type {Set.<string>}
194
+ */
195
+ export const PLATFORM_FUNCTION_GLOBAL_ALIAS = new Set(['stringify']);
196
+
197
+ /**
198
+ * Platform.Function names (all lowercase) that have no dedicated ssjs.guide page.
199
+ * Omit these from the site-index to avoid dead links.
200
+ *
201
+ * @type {Set.<string>}
202
+ */
203
+ export const PLATFORM_FUNCTION_NO_PAGE = new Set(['contentarea', 'contentareabyname']);