@voxgig/sdkgen 4.2.7 → 4.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.
Files changed (33) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/helpers/naming.d.ts +2 -1
  3. package/dist/helpers/naming.js +50 -12
  4. package/dist/helpers/naming.js.map +1 -1
  5. package/dist/sdkgen.d.ts +2 -2
  6. package/dist/sdkgen.js +4 -3
  7. package/dist/sdkgen.js.map +1 -1
  8. package/dist/tsconfig.tsbuildinfo +1 -1
  9. package/package.json +1 -1
  10. package/project/.sdk/tm/go/test/custom_utility_test.go +103 -0
  11. package/project/.sdk/tm/go/test/feature_corpus_test.go +550 -0
  12. package/project/.sdk/tm/go/utility/make_options.go +7 -1
  13. package/project/.sdk/tm/go/utility/register.go +194 -0
  14. package/project/.sdk/tm/java/test/CustomUtilityTest.java +55 -0
  15. package/project/.sdk/tm/java/test/FeatureCorpusTest.java +463 -0
  16. package/project/.sdk/tm/java/utility/MakeOptions.java +11 -2
  17. package/project/.sdk/tm/java/utility/Register.java +91 -0
  18. package/project/.sdk/tm/js/test/feature/Corpus.test.js +24 -3
  19. package/project/.sdk/tm/perl/t/feature_corpus.t +345 -0
  20. package/project/.sdk/tm/perl/utility/make_options.pm +33 -1
  21. package/project/.sdk/tm/php/core/Context.php +3 -0
  22. package/project/.sdk/tm/php/core/Control.php +13 -0
  23. package/project/.sdk/tm/php/core/Error.php +12 -0
  24. package/project/.sdk/tm/php/test/FeatureCorpusTest.php +376 -0
  25. package/project/.sdk/tm/php/utility/MakeOptions.php +30 -1
  26. package/project/.sdk/tm/py/pkg/utility/make_options.py +42 -1
  27. package/project/.sdk/tm/py/test/test_feature_corpus.py +309 -0
  28. package/project/.sdk/tm/rb/test/feature_corpus_test.rb +281 -0
  29. package/project/.sdk/tm/rb/utility/make_options.rb +32 -1
  30. package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +24 -3
  31. package/project/sdkgen-package.json +1 -1
  32. package/src/helpers/naming.ts +54 -12
  33. package/src/sdkgen.ts +2 -1
@@ -149,9 +149,9 @@ const RB_SDK_CONSTANTS = new Set<string>([
149
149
  'StructRunner', 'StructTestClient', 'StructUtilityTest', 'VoxgigStruct',
150
150
  'STRUCT_TEST_JSON_FILE',
151
151
  // the generated/templated test classes
152
- 'ExistsTest', 'FeatureTest', 'NetsimTest', 'PipelineTest',
153
- 'PrimaryUtilityTest', 'ReadmeExamplesTest', 'TestHookFeature',
154
- 'TestInitFeature',
152
+ 'ExistsTest', 'FeatureCorpusTest', 'FeatureTest', 'NetsimTest',
153
+ 'PipelineTest', 'PrimaryUtilityTest', 'ReadmeExamplesTest',
154
+ 'TestHookFeature', 'TestInitFeature',
155
155
  ])
156
156
 
157
157
 
@@ -304,18 +304,59 @@ function isPhpReservedType(Name: string): boolean {
304
304
  }
305
305
 
306
306
 
307
- // A declarable PHP class name for a generated type: unchanged, unless PHP
308
- // reserves the word, in which case `Type` is appended (`Namespace` ->
309
- // `NamespaceType`). Mirrors rbSafeTypeName and swiftSafeTypeName deliberately
310
- // same suffix, same "only rename on an actual collision" rule, so every SDK
311
- // that does not collide is byte-identical to before.
307
+ // CLASSES THE GENERATED PHP SDK ITSELF DECLARES the second half of "already
308
+ // taken", exactly as RB_SDK_CONSTANTS is for ruby. `PHP_RESERVED_TYPES` covers
309
+ // what the LANGUAGE owns; this covers what OUR OWN scaffolding claims, which a
310
+ // keyword list can never catch.
311
+ //
312
+ // The generated PHP SDK uses NO NAMESPACES, and composer classmaps both the
313
+ // runtime (`types/`) and the tests (`autoload-dev`: `test/`). An entity named
314
+ // `feature_test` emits `class FeatureTest` in `<Sdk>Types.php` while
315
+ // `tm/php/test/FeatureTest.php` declares one too: composer maps one name to
316
+ // two files, and loading both fatals on redeclaration. Ruby's equivalent only
317
+ // warns; PHP does not.
318
+ //
319
+ // Only UNPREFIXED, UNNAMESPACED declarations are listed. `ProjectNameUtility`
320
+ // substitutes to `<Sdk>Utility`, which no bare entity type can equal, and
321
+ // `utility/struct/Struct.php` and `test/StructRunner.php` declare inside a
322
+ // namespace — neither is reachable from the global name an entity type takes.
323
+ //
324
+ // `php-sdk-classes.test.ts` re-derives this from the templates AND the
325
+ // components and fails on drift, the same discipline as the rb and swift
326
+ // guards, and for the same reason: a hand-collected list rots.
327
+ //
328
+ // Folded, and matched folded: PHP class names are case-insensitive, so
329
+ // `FeatureTest` and `featuretest` are one identifier.
330
+ const PHP_SDK_CLASSES = new Set<string>([
331
+ // the generated/templated test classes
332
+ 'existstest', 'featurecorpustest', 'featuretest', 'netsimtest',
333
+ 'pipelinetest', 'primaryutilitytest', 'readmeexamplestest',
334
+ 'structutilitytest',
335
+ // helper classes those suites declare beside them
336
+ 'ftclient', 'ftclock', 'ftctrl', 'ftentity', 'ftharness', 'ftrecorder',
337
+ 'plclient', 'plentity', 'plentityitem',
338
+ ])
339
+
340
+
341
+ // Does `Name` collide with a class the generated PHP SDK already declares?
342
+ function isPhpSdkClass(Name: string): boolean {
343
+ return PHP_SDK_CLASSES.has(String(Name).toLowerCase())
344
+ }
345
+
346
+
347
+ // A declarable PHP class name for a generated type: unchanged, unless the name
348
+ // is ALREADY TAKEN — by PHP itself, or by the SDK's own scaffolding — in which
349
+ // case `Type` is appended (`Namespace` -> `NamespaceType`). Mirrors
350
+ // rbSafeTypeName and swiftSafeTypeName deliberately — same suffix, same "only
351
+ // rename on an actual collision" rule, so every SDK that does not collide is
352
+ // byte-identical to before.
312
353
  //
313
354
  // Applied ONLY to the bare entity data class. Per-op type names already carry
314
- // their own suffix (`NamespaceLoadData`, `NamespaceCreateData`), which no
315
- // reserved word matches, and the entity ACCESSOR is a method rather than a
316
- // class — PHP resolves those separately — so the public surface is unchanged.
355
+ // their own suffix (`NamespaceLoadData`, `NamespaceCreateData`), which neither
356
+ // set matches, and the entity ACCESSOR is a method rather than a class — PHP
357
+ // resolves those separately — so the public surface is unchanged.
317
358
  function phpSafeTypeName(Name: string): string {
318
- return isPhpReservedType(Name) ? Name + 'Type' : Name
359
+ return isPhpReservedType(Name) || isPhpSdkClass(Name) ? Name + 'Type' : Name
319
360
  }
320
361
 
321
362
 
@@ -496,6 +537,7 @@ export {
496
537
  isSwiftSdkType,
497
538
  swiftSafeTypeName,
498
539
  isPhpReservedType,
540
+ isPhpSdkClass,
499
541
  phpSafeTypeName,
500
542
  isTsReservedType,
501
543
  tsSafeTypeName,
package/src/sdkgen.ts CHANGED
@@ -59,7 +59,7 @@ import { collectDeps } from './helpers/collectDeps'
59
59
  import type { DepEntry } from './helpers/collectDeps'
60
60
  import { canonToType, canonToDtype, canonKey, canonScalarKey } from './helpers/canonType'
61
61
  import { OP_SUFFIX, opTypeName, opParams, ownPoint, opActions, entityActions, entityPath, opRequestShape, entityIdField, entityDataIdField, entityOps, entityPrimaryOp, pickExampleEntity, entityClassName, entityTypeCollisions, warnEntityTypeCollisions, deriveEntityNames, entityCollection } from './helpers/opShape'
62
- import { isReservedName, safeVarName, exampleVarName, phpEntityAccessor, entityCacheField, isRbCoreConstant, isRbSdkConstant, rbSafeTypeName, isSwiftSdkType, swiftSafeTypeName, isPhpReservedType, phpSafeTypeName, isTsReservedType, tsSafeTypeName, jsProp, jsOptProp, jsKey } from './helpers/naming'
62
+ import { isReservedName, safeVarName, exampleVarName, phpEntityAccessor, entityCacheField, isRbCoreConstant, isRbSdkConstant, rbSafeTypeName, isSwiftSdkType, swiftSafeTypeName, isPhpReservedType, isPhpSdkClass, phpSafeTypeName, isTsReservedType, tsSafeTypeName, jsProp, jsOptProp, jsKey } from './helpers/naming'
63
63
  import { serverVariables, hasServerVariables } from './helpers/serverVars'
64
64
  import { primaryOpCall, idLiteral, matchArg, dataArg, litFor } from './helpers/opExample'
65
65
  import type { ExampleLang } from './helpers/opExample'
@@ -1126,6 +1126,7 @@ export {
1126
1126
  isSwiftSdkType,
1127
1127
  swiftSafeTypeName,
1128
1128
  isPhpReservedType,
1129
+ isPhpSdkClass,
1129
1130
  phpSafeTypeName,
1130
1131
  isTsReservedType,
1131
1132
  tsSafeTypeName,