@servicenow/sdk-build-plugins 4.6.0 → 4.6.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.
Files changed (45) hide show
  1. package/dist/acl-plugin.js +3 -1
  2. package/dist/acl-plugin.js.map +1 -1
  3. package/dist/atf/test-plugin.js +6 -8
  4. package/dist/atf/test-plugin.js.map +1 -1
  5. package/dist/basic-syntax-plugin.js +10 -3
  6. package/dist/basic-syntax-plugin.js.map +1 -1
  7. package/dist/column-plugin.js +96 -42
  8. package/dist/column-plugin.js.map +1 -1
  9. package/dist/now-config-plugin.js +1 -0
  10. package/dist/now-config-plugin.js.map +1 -1
  11. package/dist/record-plugin.js +3 -2
  12. package/dist/record-plugin.js.map +1 -1
  13. package/dist/script-include-plugin.js +4 -0
  14. package/dist/script-include-plugin.js.map +1 -1
  15. package/dist/service-catalog/catalog-clientscript-plugin.js +2 -2
  16. package/dist/service-catalog/catalog-clientscript-plugin.js.map +1 -1
  17. package/dist/service-catalog/catalog-ui-policy-plugin.js +2 -2
  18. package/dist/service-catalog/catalog-ui-policy-plugin.js.map +1 -1
  19. package/dist/service-catalog/service-catalog-base.d.ts +2 -2
  20. package/dist/service-catalog/service-catalog-base.js +2 -2
  21. package/dist/service-catalog/service-catalog-base.js.map +1 -1
  22. package/dist/service-catalog/utils.js +1 -1
  23. package/dist/service-catalog/utils.js.map +1 -1
  24. package/dist/table-plugin.js +201 -55
  25. package/dist/table-plugin.js.map +1 -1
  26. package/dist/ui-policy-plugin.js +28 -96
  27. package/dist/ui-policy-plugin.js.map +1 -1
  28. package/dist/utils.d.ts +5 -1
  29. package/dist/utils.js +41 -0
  30. package/dist/utils.js.map +1 -1
  31. package/package.json +4 -4
  32. package/src/acl-plugin.ts +3 -1
  33. package/src/atf/test-plugin.ts +6 -9
  34. package/src/basic-syntax-plugin.ts +11 -3
  35. package/src/column-plugin.ts +134 -67
  36. package/src/now-config-plugin.ts +1 -0
  37. package/src/record-plugin.ts +11 -3
  38. package/src/script-include-plugin.ts +8 -0
  39. package/src/service-catalog/catalog-clientscript-plugin.ts +2 -2
  40. package/src/service-catalog/catalog-ui-policy-plugin.ts +2 -2
  41. package/src/service-catalog/service-catalog-base.ts +2 -2
  42. package/src/service-catalog/utils.ts +1 -1
  43. package/src/table-plugin.ts +254 -77
  44. package/src/ui-policy-plugin.ts +32 -128
  45. package/src/utils.ts +52 -0
package/dist/utils.js CHANGED
@@ -8,9 +8,11 @@ exports.applyPathMappings = applyPathMappings;
8
8
  exports.getCallExpressionName = getCallExpressionName;
9
9
  exports.generateDeprecatedDiagnostics = generateDeprecatedDiagnostics;
10
10
  exports.validateClientSideScript = validateClientSideScript;
11
+ exports.generateChoiceSetFile = generateChoiceSetFile;
11
12
  exports.createSdkDocEntry = createSdkDocEntry;
12
13
  exports.getFieldAsNumber = getFieldAsNumber;
13
14
  const sdk_build_core_1 = require("@servicenow/sdk-build-core");
15
+ const xmlbuilder2_1 = require("xmlbuilder2");
14
16
  function toReference(shape) {
15
17
  return shape.ifRecord()?.getId() ?? shape.ifString()?.getValue() ?? '';
16
18
  }
@@ -115,6 +117,45 @@ const showGuidFieldDiagnostic = (inputReceived, fieldName, tableName, diagnostic
115
117
  }
116
118
  };
117
119
  exports.showGuidFieldDiagnostic = showGuidFieldDiagnostic;
120
+ async function generateChoiceSetFile(choiceSet, choices, config, transform) {
121
+ const tableName = choiceSet.get('name').asString().getValue();
122
+ const elementName = choiceSet.get('element').asString().getValue();
123
+ const xml = (0, xmlbuilder2_1.create)().ele('record_update');
124
+ const root = xml.ele('sys_choice_set', { table: tableName, field: elementName });
125
+ choices.forEach((choice) => {
126
+ const child = root.ele('sys_choice', { action: choice.getAction() });
127
+ child.ele('sys_id').txt(choice.getId().getValue());
128
+ child.ele('name').txt(tableName);
129
+ child.ele('element').txt(elementName);
130
+ for (const prop of [
131
+ 'label',
132
+ 'value',
133
+ 'sequence',
134
+ 'dependent_value',
135
+ 'hint',
136
+ 'inactive',
137
+ 'inactive_on_update',
138
+ 'language',
139
+ ]) {
140
+ choice
141
+ .get(prop)
142
+ .ifDefined()
143
+ ?.toString()
144
+ .pipe((p) => child.ele(prop).txt(p.getValue()));
145
+ }
146
+ });
147
+ const child = root.ele('sys_choice_set', { action: choiceSet.getAction() });
148
+ child.ele('sys_id').txt(choiceSet.getId().getValue());
149
+ child.ele('sys_scope', { display_value: config.scope }).txt(config.scopeId);
150
+ child.ele('name').txt(tableName);
151
+ child.ele('element').txt(elementName);
152
+ return {
153
+ source: choiceSet,
154
+ name: `${await transform.getUpdateName(choiceSet)}.xml`,
155
+ category: choiceSet.getInstallCategory(),
156
+ content: xml.end({ prettyPrint: true }),
157
+ };
158
+ }
118
159
  /**
119
160
  * Creates a documentation entry for first-party SDK plugins.
120
161
  *
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAUA,kCAEC;AAQD,sCASC;AAED,0BAMC;AASD,8CAYC;AAED,sDAOC;AAED,sEAOC;AAkBD,4DAQC;AAqCD,8CAKC;AAMD,4CAOC;AA7JD,+DAQmC;AAEnC,SAAgB,WAAW,CAAC,KAAY;IACpC,OAAO,KAAK,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;AAC1E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAAqC,GAAiB;IAC/E,MAAM,QAAQ,GAAG,EAAkB,CAAA;IACnC,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;QACtB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,QAAQ,CAAC,KAAK,CAAC,GAAG,GAAG,CAAA;QACzB,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAA;A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AAO;QACH,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,GAAG,MAAM,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC,MAAM;QACvD,QAAQ,EAAE,SAAS,CAAC,kBAAkB,EAAE;QACxC,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;KAC1C,CAAA;AACL,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,OAAe,EAAE,IAAc;IAC7D,OAAO;QACH,OAAO;QACP,IAAI;KACP,CAAA;AACL,CAAC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,KAAmB,EAAE,SAAiB,EAAE,YAAqB;IAC1F,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;IACjD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,EAAE,EAAE,CAAC;QACjE,OAAO,YAAY,CAAA;IACvB,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC/B,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAA;AACvD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicenow/sdk-build-plugins",
3
- "version": "4.6.0",
3
+ "version": "4.6.1",
4
4
  "description": "ServiceNow SDK Build System Plugins",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -28,9 +28,9 @@
28
28
  "xmlbuilder2": "3.1.1",
29
29
  "xml-js": "1.6.11",
30
30
  "zod": "3.23.8",
31
- "@servicenow/sdk-build-core": "4.6.0",
32
- "@servicenow/sdk-core": "4.6.0",
33
- "@servicenow/sdk-repack": "4.6.0"
31
+ "@servicenow/sdk-build-core": "4.6.1",
32
+ "@servicenow/sdk-repack": "4.6.1",
33
+ "@servicenow/sdk-core": "4.6.1"
34
34
  },
35
35
  "overrides": {
36
36
  "micromatch": "4.0.7"
package/src/acl-plugin.ts CHANGED
@@ -82,7 +82,9 @@ export const AclPlugin = Plugin.create({
82
82
  $id: $.val(NowIdShape.from(record)),
83
83
  condition: $.def(''),
84
84
  description: $.def(''),
85
- localOrExisting: $.from('local_or_existing').def('Local'),
85
+ localOrExisting: $.from('local_or_existing')
86
+ .map((v) => (v.ifString()?.isEmpty() ? undefined : v))
87
+ .def('Local'),
86
88
  active: $.toBoolean().def(true),
87
89
  decisionType: $.from('decision_type').def('allow'),
88
90
  adminOverrides: $.from('admin_overrides').toBoolean().def(true),
@@ -148,14 +148,11 @@ export const TestPlugin = Plugin.create({
148
148
  })
149
149
  : callExpression
150
150
  })
151
- const arrowFunction =
152
- statements.length > 0
153
- ? new ArrowFunctionShape({
154
- source: record,
155
- parameters: [arrowParameter],
156
- statements,
157
- })
158
- : undefined
151
+ const arrowFunction = new ArrowFunctionShape({
152
+ source: record,
153
+ parameters: [arrowParameter],
154
+ statements,
155
+ })
159
156
 
160
157
  return {
161
158
  success: true,
@@ -171,7 +168,7 @@ export const TestPlugin = Plugin.create({
171
168
  failOnServerError: $.from('fail_on_server_error').toBoolean().def(false),
172
169
  })),
173
170
  arrowFunction,
174
- ].filter((arg) => arg),
171
+ ],
175
172
  }),
176
173
  }
177
174
  },
@@ -27,6 +27,7 @@ import {
27
27
  Record as DBRecord,
28
28
  asDataHelper,
29
29
  isValidNode,
30
+ NowConfig,
30
31
  } from '@servicenow/sdk-build-core'
31
32
  import { isDataHelper } from './data-plugin'
32
33
  import { getCallExpressionName } from './utils'
@@ -81,9 +82,16 @@ export const BasicSyntaxPlugin = Plugin.create({
81
82
  const tableName =
82
83
  shape.getSource() instanceof DBRecord ? (shape.getSource() as DBRecord).getTable() : undefined
83
84
 
84
- const dir =
85
- tableName && taxonomy.mapping[tableName]
86
- ? pathModule.join(generatedDir, taxonomy.mapping[tableName])
85
+ const hostedDir = NowConfig.getHostedDirectory(config, source.path)
86
+ const conditionalDir = NowConfig.getConditionalDirectory(config, source.path)
87
+ const taxonomySubdir = tableName && taxonomy.mapping[tableName] ? taxonomy.mapping[tableName] : ''
88
+
89
+ const dir = hostedDir
90
+ ? pathModule.join(generatedDir, hostedDir)
91
+ : conditionalDir
92
+ ? pathModule.join(generatedDir, conditionalDir)
93
+ : taxonomySubdir
94
+ ? pathModule.join(generatedDir, taxonomySubdir)
87
95
  : generatedDir
88
96
 
89
97
  let name = pathModule.basename(source.path).replace(RegExp(`${pathModule.extname(source.path)}$`), '')
@@ -9,8 +9,7 @@ import {
9
9
  getDefaultMaxLength,
10
10
  } from './column/column-helper'
11
11
  import { ModuleFunctionShape } from './server-module-plugin'
12
- import { generateDeprecatedDiagnostics } from './utils'
13
- import { create } from 'xmlbuilder2'
12
+ import { generateDeprecatedDiagnostics, generateChoiceSetFile } from './utils'
14
13
 
15
14
  // BCP 47 language tag pattern: 2-3 letter base language with optional subtags (e.g., 'en', 'zh-Hans', 'en-US')
16
15
  export const BCP47_LANGUAGE_TAG_PATTERN = /^[a-z]{2,3}(-[a-zA-Z0-9]{2,8})*$/
@@ -48,6 +47,9 @@ const columnAliases = {
48
47
  referenceKey: ['reference_key'],
49
48
  referenceQual: ['reference_qual'],
50
49
  columnType: ['column_type'],
50
+ virtualType: ['virtual_type'],
51
+ useReferenceQualifier: ['use_reference_qualifier'],
52
+ dynamicRefQual: ['dynamic_ref_qual'],
51
53
  }
52
54
 
53
55
  const calculationAliases = {
@@ -92,48 +94,9 @@ export const ColumnPlugin = Plugin.create({
92
94
  value: `sys_choice_${record.get('name').getValue()}_${record.get('element').getValue()}`,
93
95
  }),
94
96
  async toFile(choiceSet, { config, descendants, transform }) {
95
- const tableName = choiceSet.get('name').asString().getValue()
96
- const elementName = choiceSet.get('element').asString().getValue()
97
- const xml = create().ele('record_update')
98
- const root = xml.ele('sys_choice_set', { table: tableName, field: elementName })
99
- descendants.query('sys_choice').forEach((choice) => {
100
- const child = root.ele('sys_choice', { action: choice.getAction() })
101
- child.ele('sys_id').txt(choice.getId().getValue())
102
- child.ele('name').txt(tableName)
103
- child.ele('element').txt(elementName)
104
-
105
- for (const prop of [
106
- 'label',
107
- 'value',
108
- 'sequence',
109
- 'dependent_value',
110
- 'hint',
111
- 'inactive',
112
- 'inactive_on_update',
113
- 'language',
114
- ]) {
115
- choice
116
- .get(prop)
117
- .ifDefined()
118
- ?.toString()
119
- .pipe((p) => child.ele(prop).txt(p.getValue()))
120
- }
121
- })
122
-
123
- const child = root.ele('sys_choice_set', { action: choiceSet.getAction() })
124
- child.ele('sys_id').txt(choiceSet.getId().getValue())
125
- child.ele('sys_scope', { display_value: config.scope }).txt(config.scopeId)
126
- child.ele('name').txt(tableName)
127
- child.ele('element').txt(elementName)
128
-
129
97
  return {
130
98
  success: true,
131
- value: {
132
- source: choiceSet,
133
- name: `${await transform.getUpdateName(choiceSet)}.xml`,
134
- category: choiceSet.getInstallCategory(),
135
- content: xml.end({ prettyPrint: true }),
136
- },
99
+ value: await generateChoiceSetFile(choiceSet, descendants.query('sys_choice'), config, transform),
137
100
  }
138
101
  },
139
102
  },
@@ -183,6 +146,17 @@ export const ColumnPlugin = Plugin.create({
183
146
  )
184
147
  }
185
148
  const columnType = COLUMN_API_TO_TYPE[callee] ?? column.get('columnType').asString().getValue()
149
+
150
+ const dynamicRefQualShape = column.get('dynamicRefQual')
151
+ const dynamicRefQualRef =
152
+ dynamicRefQualShape.isString() && dynamicRefQualShape.getValue() !== ''
153
+ ? await factory.createReference({
154
+ source: dynamicRefQualShape,
155
+ table: 'sys_filter_option_dynamic',
156
+ guid: dynamicRefQualShape,
157
+ })
158
+ : dynamicRefQualShape.ifDefined()
159
+
186
160
  return {
187
161
  success: true,
188
162
  value: (
@@ -270,8 +244,12 @@ export const ColumnPlugin = Plugin.create({
270
244
  ? dynamicValueDefinitions.asObject().get('table').ifString()
271
245
  : undefined
272
246
  ),
273
- virtual: $.from('dynamicValueDefinitions')
274
- .map((dynamicValueDefinitions) => {
247
+ virtual: $.from('dynamicValueDefinitions', 'formula')
248
+ .map((dynamicValueDefinitions, formula) => {
249
+ const hasFormula = formula.isString() && formula.getValue() !== ''
250
+ if (hasFormula) {
251
+ return true
252
+ }
275
253
  const calculationType = dynamicValueDefinitions
276
254
  .ifObject()
277
255
  ?.get('type')
@@ -382,6 +360,50 @@ export const ColumnPlugin = Plugin.create({
382
360
  unique: $.toBoolean().def(false),
383
361
  widget: $,
384
362
  xml_view: $.from('xmlView').toBoolean().def(false),
363
+ formula: $.from('formula').toCdata(),
364
+ virtual_type: $.from('virtualType', 'formula')
365
+ .map((virtualType, formula) => {
366
+ const explicit = virtualType.ifString()?.getValue()
367
+ const hasFormula = formula.isString() && formula.getValue() !== ''
368
+ const derived = hasFormula ? 'formula' : 'script'
369
+ if (explicit && explicit !== derived) {
370
+ const reason = hasFormula
371
+ ? `formula is set, implying 'formula'`
372
+ : `formula is not set, implying 'script'`
373
+ diagnostics.warn(
374
+ virtualType,
375
+ `virtualType is set to '${explicit}' but ${reason}. The explicit value '${explicit}' will be used.`
376
+ )
377
+ return explicit
378
+ }
379
+ return derived
380
+ })
381
+ .def('script'),
382
+ use_reference_qualifier: $.from('useReferenceQualifier', 'referenceQual')
383
+ .map((useReferenceQualifier, referenceQual) => {
384
+ const explicit = useReferenceQualifier.ifString()?.getValue()
385
+ const hasDynamic = !!dynamicRefQualRef
386
+ const hasRef = referenceQual.isString() && referenceQual.getValue() !== ''
387
+ const derived = hasDynamic ? 'dynamic' : hasRef ? 'advanced' : 'simple'
388
+ if (explicit && explicit !== derived) {
389
+ const reason =
390
+ hasDynamic && hasRef
391
+ ? `both dynamicRefQual and referenceQual are set`
392
+ : hasDynamic
393
+ ? `dynamicRefQual is set, implying 'dynamic'`
394
+ : hasRef
395
+ ? `referenceQual is set, implying 'advanced'`
396
+ : `neither dynamicRefQual nor referenceQual is set, implying 'simple'`
397
+ diagnostics.warn(
398
+ useReferenceQualifier,
399
+ `useReferenceQualifier is set to '${explicit}' but ${reason}. The explicit value '${explicit}' will be used.`
400
+ )
401
+ return explicit
402
+ }
403
+ return derived
404
+ })
405
+ .def('simple'),
406
+ dynamic_ref_qual: $.val(dynamicRefQualRef),
385
407
  })),
386
408
  })
387
409
  ).with(...documentationRecords, ...choiceRecords, ...choiceSetRecords),
@@ -559,31 +581,40 @@ export function columnToCallExpression(
559
581
  return dropdownIndex !== -1 ? choiceDropdown[dropdownIndex] : undefined
560
582
  })
561
583
  .def('none'),
562
- dynamicValueDefinitions: $.from('calculation', 'choice_table', 'choice_field').map(
563
- (calculation, choiceTable, choiceField) => {
564
- if (
565
- calculation.ifString()?.getValue() &&
566
- calculation.asString().getValue() !== DEFAULT_COLUMN_CALCULATION
567
- ) {
568
- return new ObjectShape({
569
- source: calculation,
570
- properties: {
571
- type: 'calculated_value',
572
- calculatedValue: calculation,
573
- },
574
- }).withAliasedKeys(calculationAliases)
575
- }
576
- if (choiceTable.ifString()?.getValue() && choiceField.ifString()?.getValue()) {
577
- return {
578
- type: 'choices_from_other_table',
579
- table: choiceTable.asString().getValue(),
580
- field: choiceField.asString().getValue(),
581
- }
584
+ dynamicValueDefinitions: $.from(
585
+ 'calculation',
586
+ 'choice_table',
587
+ 'choice_field',
588
+ 'virtual_type',
589
+ 'virtual'
590
+ ).map((calculation, choiceTable, choiceField, virtualType, virtual) => {
591
+ // Server only reads calculation when virtual_type='script' and virtual=true
592
+ const vType = virtualType.ifString()?.getValue()
593
+ const isVirtual = virtual.ifBoolean()?.getValue() ?? virtual.ifString()?.getValue() === 'true'
594
+ if (
595
+ isVirtual &&
596
+ vType !== 'formula' &&
597
+ calculation.ifString()?.getValue() &&
598
+ calculation.asString().getValue() !== DEFAULT_COLUMN_CALCULATION
599
+ ) {
600
+ return new ObjectShape({
601
+ source: calculation,
602
+ properties: {
603
+ type: 'calculated_value',
604
+ calculatedValue: calculation,
605
+ },
606
+ }).withAliasedKeys(calculationAliases)
607
+ }
608
+ if (choiceTable.ifString()?.getValue() && choiceField.ifString()?.getValue()) {
609
+ return {
610
+ type: 'choices_from_other_table',
611
+ table: choiceTable.asString().getValue(),
612
+ field: choiceField.asString().getValue(),
582
613
  }
583
-
584
- return undefined
585
614
  }
586
- ),
615
+
616
+ return undefined
617
+ }),
587
618
  // Direct dependent parameter for DocumentIdColumn, TemplateValueColumn, and FieldListColumn
588
619
  dependent: $.from('dependent').map((dependent) => {
589
620
  if (dependent?.isString()) {
@@ -645,6 +676,42 @@ export function columnToCallExpression(
645
676
  unique: $.toBoolean().def(false),
646
677
  widget: $.def(''),
647
678
  xmlView: $.from('xml_view').toBoolean().def(false),
679
+ formula: $.from('virtual_type', 'formula').map((virtualType, formula) => {
680
+ // Server only reads formula when virtual_type='formula'
681
+ if (virtualType.ifString()?.getValue() !== 'formula') {
682
+ return undefined
683
+ }
684
+ return formula.ifString()?.ifNotEmpty()
685
+ }),
686
+ virtualType: $.from('virtual_type', 'formula').map((virtualType, formula) => {
687
+ const qualifier = virtualType.ifString()?.getValue()
688
+ const hasFormula = formula.isString() && formula.getValue() !== ''
689
+ if (hasFormula && qualifier === 'formula') {
690
+ return undefined
691
+ }
692
+ if (!hasFormula && (!qualifier || qualifier === 'script')) {
693
+ return undefined
694
+ }
695
+ return qualifier
696
+ }),
697
+ useReferenceQualifier: $.from('use_reference_qualifier', 'dynamic_ref_qual', 'reference_qual').map(
698
+ (useReferenceQualifier, dynamicRefQual, referenceQual) => {
699
+ const qualifier = useReferenceQualifier.ifString()?.getValue()
700
+ const hasDynamicRefQual = dynamicRefQual.isString() && dynamicRefQual.getValue() !== ''
701
+ const hasReferenceQual = referenceQual.isString() && referenceQual.getValue() !== ''
702
+ if (hasDynamicRefQual && qualifier === 'dynamic') {
703
+ return undefined
704
+ }
705
+ if (hasReferenceQual && qualifier === 'advanced') {
706
+ return undefined
707
+ }
708
+ if (!hasDynamicRefQual && !hasReferenceQual && (!qualifier || qualifier === 'simple')) {
709
+ return undefined
710
+ }
711
+ return qualifier
712
+ }
713
+ ),
714
+ dynamicRefQual: $.from('dynamic_ref_qual').def(''),
648
715
  }))
649
716
  .withAliasedKeys(columnAliases),
650
717
  ],
@@ -937,6 +937,7 @@ export const NowConfigPlugin = Plugin.create({
937
937
  package_resolver_version: $.from('packageResolverVersion').def(
938
938
  scope === 'global' ? MODULE_RESOLUTION.V2 : MODULE_RESOLUTION.V1
939
939
  ),
940
+ sys_code: $.from('scope'),
940
941
  })),
941
942
  })
942
943
 
@@ -1,4 +1,11 @@
1
- import { CallExpressionShape, Database, Plugin, unloadBuilder, type Record } from '@servicenow/sdk-build-core'
1
+ import {
2
+ CallExpressionShape,
3
+ Database,
4
+ NowConfig,
5
+ Plugin,
6
+ unloadBuilder,
7
+ type Record,
8
+ } from '@servicenow/sdk-build-core'
2
9
  import { NowIdShape } from './now-id-plugin'
3
10
  import { createSdkDocEntry } from './utils'
4
11
  import {
@@ -116,9 +123,10 @@ export const RecordPlugin = Plugin.create({
116
123
  }
117
124
  },
118
125
  async toFile(record, { config, database, transform }) {
126
+ const { scope, scopeId } = NowConfig.getRecordScope(config, record.getOriginalFilePath())
119
127
  const recordBuilder = unloadBuilder({
120
- scope: config.scope,
121
- scopeId: config.scopeId,
128
+ scope,
129
+ scopeId,
122
130
  table: record.getTable(),
123
131
  })
124
132
  const updateName = await transform.getUpdateName(record)
@@ -61,6 +61,14 @@ export const ScriptIncludePlugin = Plugin.create({
61
61
  diagnostics.error(name.getOriginalNode(), `name must be a valid JavaScript identifier`)
62
62
  }
63
63
 
64
+ const callerAccess = prop.get('callerAccess')
65
+ if (callerAccess.isDefined() && prop.get('accessibleFrom').ifString()?.getValue() !== 'public') {
66
+ diagnostics.hint(
67
+ callerAccess.getOriginalNode(),
68
+ `'callerAccess' is only effective when 'accessibleFrom' is set to 'public'. It is ignored by the platform otherwise.`
69
+ )
70
+ }
71
+
64
72
  const apiName = prop.get('apiName')
65
73
 
66
74
  if (apiName.isDefined()) {
@@ -58,7 +58,7 @@ export const CatalogClientScriptPlugin = Plugin.create({
58
58
  .map((v) =>
59
59
  v.ifString()?.isEmpty() ? undefined : getUITypeFromId(v.toNumber()?.getValue())
60
60
  )
61
- .def('desktop'),
61
+ .def('all'),
62
62
  catalogItem: $.val(catalogItemReference).def(''),
63
63
  variableName: $.val(propertyAccess).def(''),
64
64
  variableSet: $.val(variableSetReference).def(''),
@@ -130,7 +130,7 @@ export const CatalogClientScriptPlugin = Plugin.create({
130
130
  isolate_script: $.from('isolateScript').def(true),
131
131
  ui_type: $.from('uiType')
132
132
  .map((v) => (v.isString() && !v.isEmpty() ? getUITypeId(v.getValue()) : undefined))
133
- .def(0),
133
+ .def(10),
134
134
  va_supported: $.from('vaSupported').toBoolean().def(false),
135
135
  published_ref: $.from('publishedRef').def(''),
136
136
  })),
@@ -166,7 +166,7 @@ export const CatalogUiPolicyPlugin = Plugin.create({
166
166
  .map((v) =>
167
167
  v.ifString()?.isEmpty() ? undefined : getUITypeFromId(v.toNumber()?.getValue())
168
168
  )
169
- .def('desktop'),
169
+ .def('all'),
170
170
  actions: $.val(actions.length > 0 ? actions : []).def([]),
171
171
  })),
172
172
  ],
@@ -239,7 +239,7 @@ export const CatalogUiPolicyPlugin = Plugin.create({
239
239
  published_ref: $.from('publishedRef').def(''),
240
240
  ui_type: $.from('runScriptsInUiType')
241
241
  .map((v) => (v.isString() && !v.isEmpty() ? getUITypeId(v.getValue()) : undefined))
242
- .def(0),
242
+ .def(10),
243
243
  table: $.def(''),
244
244
  va_supported: $.from('vaSupported').def(true),
245
245
  view: $.def(''),
@@ -266,6 +266,7 @@ export function transformCatalogBaseFieldsToShape(record: Record, $: ShapeTransf
266
266
  .map((v: Shape) => getMobilePictureTypeFromDb(v.toString().getValue()))
267
267
  .def('desktopPicture'),
268
268
  makeItemNonConversational: $.from('make_item_non_conversational').toBoolean().def(false),
269
+ noSearch: $.from('no_search').toBoolean().def(false),
269
270
  }
270
271
  }
271
272
 
@@ -349,6 +350,7 @@ export function transformCatalogItemBaseFieldsToRecord($: ShapeTransform) {
349
350
  .map((v: Shape) => getMobilePictureTypeToDb(v.toString().getValue()))
350
351
  .def('use_desktop_picture'),
351
352
  make_item_non_conversational: $.from('makeItemNonConversational').def(false),
353
+ no_search: $.from('noSearch').def(false),
352
354
  }
353
355
  }
354
356
 
@@ -406,7 +408,6 @@ export function transformCatalogItemSpecificFieldsToShape(record: Record, $: Sha
406
408
  noOrderNow: $.from('no_order_now').toBoolean().def(false),
407
409
  noProceedCheckout: $.from('no_proceed_checkout').toBoolean().def(false),
408
410
  noQuantity: $.from('no_quantity').toBoolean().def(false),
409
- noSearch: $.from('no_search').toBoolean().def(false),
410
411
 
411
412
  // Additional fields
412
413
  vendor: $.def(''),
@@ -468,7 +469,6 @@ export function transformCatalogItemSpecificFieldsToRecord(arg: ObjectShape, $:
468
469
  no_order_now: $.from('noOrderNow').def(false),
469
470
  no_proceed_checkout: $.from('noProceedCheckout').def(false),
470
471
  no_quantity: $.from('noQuantity').def(false),
471
- no_search: $.from('noSearch').def(false),
472
472
 
473
473
  // Additional
474
474
  vendor: $.def(''),
@@ -318,7 +318,7 @@ export function getUITypeId(value: string): number {
318
318
  case 'all':
319
319
  return 10
320
320
  default:
321
- return 0 // Default to desktop
321
+ return 10 // Default to all
322
322
  }
323
323
  }
324
324