ssjs-data 0.2.1 → 0.3.0

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/README.md CHANGED
@@ -18,21 +18,82 @@ npm install ssjs-data
18
18
 
19
19
  ```js
20
20
  import {
21
+ // Globals
21
22
  SSJS_GLOBALS,
22
23
  SSJS_GLOBALS_MAP,
24
+ ssjsGlobalsLookup,
25
+ // Platform methods
23
26
  PLATFORM_METHODS,
24
27
  PLATFORM_FUNCTIONS,
25
28
  platformFunctionLookup,
26
29
  platformFunctionNames,
30
+ // Platform objects
31
+ PLATFORM_VARIABLE_METHODS,
32
+ platformVariableLookup,
33
+ PLATFORM_RESPONSE_METHODS,
34
+ platformResponseLookup,
35
+ PLATFORM_REQUEST_METHODS,
36
+ platformRequestLookup,
37
+ PLATFORM_RECIPIENT_METHODS,
38
+ platformRecipientMethodNames,
39
+ platformRecipientLookup,
40
+ // Core library objects
27
41
  CORE_LIBRARY_OBJECTS,
28
42
  coreObjectNames,
29
43
  coreObjectLookup,
44
+ coreMethodArityLookup,
45
+ // HTTP + HTTPHeader
30
46
  HTTP_METHODS,
31
47
  httpMethodNames,
48
+ httpMethodLookup,
49
+ HTTPHEADER_METHODS,
50
+ httpHeaderMethodNames,
51
+ httpHeaderMethodLookup,
52
+ // WSProxy
32
53
  WSPROXY_METHODS,
33
54
  wsproxyMethodNames,
55
+ wsproxyMethodLookup,
56
+ // WSProxy object-specific method arrays
57
+ ACCOUNT_METHODS,
58
+ ACCOUNT_TRACKING_METHODS,
59
+ ACCOUNT_USER_METHODS,
60
+ ATTRIBUTE_METHODS,
61
+ attributeMethodNames,
62
+ attributeMethodLookup,
63
+ CONTENT_AREA_OBJ_METHODS,
64
+ DATA_EXTENSION_METHODS,
65
+ DATA_EXTENSION_FIELDS_METHODS,
66
+ DATA_EXTENSION_ROWS_METHODS,
67
+ DELIVERY_PROFILE_METHODS,
68
+ EMAIL_METHODS,
69
+ EVENT_METHODS,
70
+ FILTER_DEFINITION_METHODS,
71
+ FOLDER_METHODS,
72
+ LIST_METHODS,
73
+ LIST_SUBSCRIBERS_METHODS,
74
+ LIST_SUBSCRIBERS_TRACKING_METHODS,
75
+ PORTFOLIO_METHODS,
76
+ QUERY_DEFINITION_METHODS,
77
+ SEND_METHODS,
78
+ SEND_CLASSIFICATION_METHODS,
79
+ SEND_DEFINITION_METHODS,
80
+ SEND_TRACKING_METHODS,
81
+ SENDER_PROFILE_METHODS,
82
+ SUBSCRIBER_METHODS,
83
+ SUBSCRIBER_ATTRIBUTES_METHODS,
84
+ SUBSCRIBER_LISTS_METHODS,
85
+ TEMPLATE_METHODS,
86
+ TRIGGERED_SEND_METHODS,
87
+ TRIGGERED_SEND_TRACKING_METHODS,
88
+ TRIGGERED_SEND_TRACKING_CLICKS_METHODS,
89
+ TRIGGERED_SEND_TRACKING_TOTAL_BY_INTERVAL_METHODS,
90
+ // DateTime / ErrorUtil
91
+ DATE_TIME_TIMEZONE_METHODS,
92
+ ERROR_UTIL_METHODS,
93
+ // Script.Util
34
94
  SCRIPT_UTIL_CONSTRUCTORS,
35
95
  SCRIPT_UTIL_REQUEST_METHODS,
96
+ // ECMAScript / polyfills / unsupported syntax
36
97
  ECMASCRIPT_BUILTINS,
37
98
  UNSUPPORTED_SYNTAX,
38
99
  unsupportedByNodeType,
@@ -120,12 +181,12 @@ if (coreObjectNames.has('DataExtension')) { /* ... */ }
120
181
  const de = coreObjectLookup.get('DataExtension');
121
182
  ```
122
183
 
123
- ### `HTTP_METHODS` / `httpMethodNames`
184
+ ### `HTTP_METHODS` / `httpMethodNames` / `httpMethodLookup`
124
185
 
125
186
  Methods available on the `HTTP` platform object:
126
187
 
127
188
  ```js
128
- import { HTTP_METHODS, httpMethodNames } from 'ssjs-data';
189
+ import { HTTP_METHODS, httpMethodNames, httpMethodLookup } from 'ssjs-data';
129
190
 
130
191
  for (const method of HTTP_METHODS) {
131
192
  console.log(method.name); // e.g. 'Get', 'Post'
@@ -133,14 +194,16 @@ for (const method of HTTP_METHODS) {
133
194
  }
134
195
 
135
196
  if (httpMethodNames.has('get')) { /* ... */ }
197
+
198
+ const m = httpMethodLookup.get('get');
136
199
  ```
137
200
 
138
- ### `WSPROXY_METHODS` / `wsproxyMethodNames`
201
+ ### `WSPROXY_METHODS` / `wsproxyMethodNames` / `wsproxyMethodLookup`
139
202
 
140
203
  SOAP API methods available on the `WSProxy` object:
141
204
 
142
205
  ```js
143
- import { WSPROXY_METHODS, wsproxyMethodNames } from 'ssjs-data';
206
+ import { WSPROXY_METHODS, wsproxyMethodNames, wsproxyMethodLookup } from 'ssjs-data';
144
207
 
145
208
  for (const method of WSPROXY_METHODS) {
146
209
  console.log(method.name); // e.g. 'retrieve', 'create', 'update'
@@ -148,6 +211,170 @@ for (const method of WSPROXY_METHODS) {
148
211
  }
149
212
 
150
213
  if (wsproxyMethodNames.has('retrieve')) { /* ... */ }
214
+
215
+ const method = wsproxyMethodLookup.get('retrieve');
216
+ ```
217
+
218
+ ### `HTTPHEADER_METHODS` / `httpHeaderMethodNames` / `httpHeaderMethodLookup`
219
+
220
+ Methods on the `HTTPHeader` Core object (requires `Platform.Load("core", "1")`):
221
+
222
+ ```js
223
+ import { HTTPHEADER_METHODS, httpHeaderMethodNames, httpHeaderMethodLookup } from 'ssjs-data';
224
+
225
+ for (const method of HTTPHEADER_METHODS) {
226
+ console.log(method.name); // 'GetValue', 'SetValue'
227
+ console.log(method.syntax);
228
+ }
229
+
230
+ if (httpHeaderMethodNames.has('getvalue')) { /* ... */ }
231
+ const method2 = httpHeaderMethodLookup.get('getvalue');
232
+ ```
233
+
234
+ ### `PLATFORM_VARIABLE_METHODS` / `platformVariableLookup`
235
+
236
+ Methods on the `Platform.Variable` bridge (reads and writes AMPscript variables from SSJS):
237
+
238
+ ```js
239
+ import { PLATFORM_VARIABLE_METHODS, platformVariableLookup } from 'ssjs-data';
240
+
241
+ for (const method of PLATFORM_VARIABLE_METHODS) {
242
+ console.log(method.name); // 'GetValue', 'SetValue'
243
+ }
244
+ const m = platformVariableLookup.get('getvalue');
245
+ ```
246
+
247
+ ### `PLATFORM_RESPONSE_METHODS` / `platformResponseLookup`
248
+
249
+ Methods on the `Platform.Response` object (HTTP response control):
250
+
251
+ ```js
252
+ import { PLATFORM_RESPONSE_METHODS, platformResponseLookup } from 'ssjs-data';
253
+
254
+ for (const method of PLATFORM_RESPONSE_METHODS) {
255
+ console.log(method.name); // e.g. 'Write', 'Redirect', 'SetResponseHeader'
256
+ }
257
+ const m = platformResponseLookup.get('write');
258
+ ```
259
+
260
+ ### `PLATFORM_REQUEST_METHODS` / `platformRequestLookup`
261
+
262
+ Methods on the `Platform.Request` object (HTTP request introspection):
263
+
264
+ ```js
265
+ import { PLATFORM_REQUEST_METHODS, platformRequestLookup } from 'ssjs-data';
266
+
267
+ for (const method of PLATFORM_REQUEST_METHODS) {
268
+ console.log(method.name); // e.g. 'GetQueryStringParameter', 'GetPostData'
269
+ }
270
+ const m = platformRequestLookup.get('getquerystringparameter');
271
+ ```
272
+
273
+ ### `PLATFORM_RECIPIENT_METHODS` / `platformRecipientMethodNames` / `platformRecipientLookup`
274
+
275
+ Methods on the `Platform.Recipient` object (subscriber / recipient data):
276
+
277
+ ```js
278
+ import { PLATFORM_RECIPIENT_METHODS, platformRecipientMethodNames, platformRecipientLookup } from 'ssjs-data';
279
+
280
+ for (const method of PLATFORM_RECIPIENT_METHODS) {
281
+ console.log(method.name); // e.g. 'GetAttributeValue'
282
+ }
283
+ if (platformRecipientMethodNames.has('getattributevalue')) { /* ... */ }
284
+ const m = platformRecipientLookup.get('getattributevalue');
285
+ ```
286
+
287
+ ### `ATTRIBUTE_METHODS` / `attributeMethodNames` / `attributeMethodLookup`
288
+
289
+ Methods on the `Attribute` Core object (requires `Platform.Load("core", "1.1.5")`):
290
+
291
+ ```js
292
+ import { ATTRIBUTE_METHODS, attributeMethodNames, attributeMethodLookup } from 'ssjs-data';
293
+
294
+ for (const method of ATTRIBUTE_METHODS) {
295
+ console.log(method.name); // 'GetValue'
296
+ console.log(method.description); // reads subscriber attribute / DE field for current recipient
297
+ }
298
+ if (attributeMethodNames.has('getvalue')) { /* ... */ }
299
+ const m = attributeMethodLookup.get('getvalue');
300
+ ```
301
+
302
+ ### `DATE_TIME_TIMEZONE_METHODS`
303
+
304
+ Methods on the `DateTime.TimeZone` namespace (requires `Platform.Load("core", "1.1.5")`):
305
+
306
+ ```js
307
+ import { DATE_TIME_TIMEZONE_METHODS } from 'ssjs-data';
308
+
309
+ for (const method of DATE_TIME_TIMEZONE_METHODS) {
310
+ console.log(method.name); // 'Retrieve'
311
+ console.log(method.syntax); // 'DateTime.TimeZone.Retrieve(filter)'
312
+ }
313
+ ```
314
+
315
+ ### `ERROR_UTIL_METHODS`
316
+
317
+ Utility methods on the `ErrorUtil` namespace for WSProxy error handling (requires `Platform.Load("core", "1.1.5")`):
318
+
319
+ ```js
320
+ import { ERROR_UTIL_METHODS } from 'ssjs-data';
321
+
322
+ for (const method of ERROR_UTIL_METHODS) {
323
+ console.log(method.name); // 'ThrowWSProxyError'
324
+ console.log(method.syntax);
325
+ }
326
+ ```
327
+
328
+ ### WSProxy object-specific method arrays
329
+
330
+ Each WSProxy-accessible object has its own named export. These follow the same shape as `WSPROXY_METHODS` and are used by tooling for per-object completions and hover.
331
+
332
+ | Export | WSProxy object |
333
+ |---|---|
334
+ | `ACCOUNT_METHODS` | `Account` |
335
+ | `ACCOUNT_TRACKING_METHODS` | `Account.Tracking` |
336
+ | `ACCOUNT_USER_METHODS` | `AccountUser` |
337
+ | `CONTENT_AREA_OBJ_METHODS` | `ContentAreaObj` |
338
+ | `DATA_EXTENSION_METHODS` | `DataExtension` |
339
+ | `DATA_EXTENSION_FIELDS_METHODS` | `DataExtension.Fields` |
340
+ | `DATA_EXTENSION_ROWS_METHODS` | `DataExtension.Rows` |
341
+ | `DELIVERY_PROFILE_METHODS` | `DeliveryProfile` |
342
+ | `EMAIL_METHODS` | `Email` |
343
+ | `EVENT_METHODS` | `Event` |
344
+ | `FILTER_DEFINITION_METHODS` | `FilterDefinition` |
345
+ | `FOLDER_METHODS` | `Folder` |
346
+ | `LIST_METHODS` | `List` |
347
+ | `LIST_SUBSCRIBERS_METHODS` | `List.Subscribers` |
348
+ | `LIST_SUBSCRIBERS_TRACKING_METHODS` | `List.Subscribers.Tracking` |
349
+ | `PORTFOLIO_METHODS` | `Portfolio` |
350
+ | `QUERY_DEFINITION_METHODS` | `QueryDefinition` |
351
+ | `SEND_METHODS` | `Send` |
352
+ | `SEND_CLASSIFICATION_METHODS` | `SendClassification` |
353
+ | `SEND_DEFINITION_METHODS` | `SendDefinition` |
354
+ | `SEND_TRACKING_METHODS` | `Send.Tracking` |
355
+ | `SENDER_PROFILE_METHODS` | `SenderProfile` |
356
+ | `SUBSCRIBER_METHODS` | `Subscriber` |
357
+ | `SUBSCRIBER_ATTRIBUTES_METHODS` | `Subscriber.Attributes` |
358
+ | `SUBSCRIBER_LISTS_METHODS` | `Subscriber.Lists` |
359
+ | `TEMPLATE_METHODS` | `Template` |
360
+ | `TRIGGERED_SEND_METHODS` | `TriggeredSend` |
361
+ | `TRIGGERED_SEND_TRACKING_METHODS` | `TriggeredSend.Tracking` |
362
+ | `TRIGGERED_SEND_TRACKING_CLICKS_METHODS` | `TriggeredSend.Tracking.Clicks` |
363
+ | `TRIGGERED_SEND_TRACKING_TOTAL_BY_INTERVAL_METHODS` | `TriggeredSend.Tracking.TotalByInterval` |
364
+
365
+ ### `ssjsGlobalsLookup` / `coreMethodArityLookup`
366
+
367
+ Additional O(1) lookup maps:
368
+
369
+ ```js
370
+ import { ssjsGlobalsLookup, coreMethodArityLookup } from 'ssjs-data';
371
+
372
+ // Lookup a global by lowercase name
373
+ const writeGlobal = ssjsGlobalsLookup.get('write');
374
+
375
+ // Lookup arity (min/max args) of a Core library method by 'ObjectName.methodName'
376
+ const arity = coreMethodArityLookup.get('DataExtension.Init');
377
+ // e.g. { minArgs: 1, maxArgs: 1 }
151
378
  ```
152
379
 
153
380
  ### `SCRIPT_UTIL_CONSTRUCTORS` / `SCRIPT_UTIL_REQUEST_METHODS`