graphile-settings 4.1.0 → 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 (101) hide show
  1. package/esm/index.d.ts +1 -2
  2. package/esm/index.js +2 -4
  3. package/esm/plugins/index.d.ts +4 -13
  4. package/esm/plugins/index.js +5 -21
  5. package/esm/presets/constructive-preset.d.ts +4 -0
  6. package/esm/presets/constructive-preset.js +17 -9
  7. package/esm/upload-resolver.d.ts +43 -0
  8. package/esm/upload-resolver.js +168 -0
  9. package/index.d.ts +1 -2
  10. package/index.js +4 -7
  11. package/package.json +26 -14
  12. package/plugins/index.d.ts +4 -13
  13. package/plugins/index.js +32 -44
  14. package/presets/constructive-preset.d.ts +4 -0
  15. package/presets/constructive-preset.js +26 -18
  16. package/upload-resolver.d.ts +43 -0
  17. package/upload-resolver.js +175 -0
  18. package/esm/plugins/conflict-detector.d.ts +0 -7
  19. package/esm/plugins/conflict-detector.js +0 -67
  20. package/esm/plugins/custom-inflector.d.ts +0 -9
  21. package/esm/plugins/custom-inflector.js +0 -382
  22. package/esm/plugins/enable-all-filter-columns.d.ts +0 -60
  23. package/esm/plugins/enable-all-filter-columns.js +0 -85
  24. package/esm/plugins/inflector-logger.d.ts +0 -7
  25. package/esm/plugins/inflector-logger.js +0 -215
  26. package/esm/plugins/many-to-many-preset.d.ts +0 -62
  27. package/esm/plugins/many-to-many-preset.js +0 -86
  28. package/esm/plugins/meta-schema/cache.d.ts +0 -4
  29. package/esm/plugins/meta-schema/cache.js +0 -7
  30. package/esm/plugins/meta-schema/constraint-meta-builders.d.ts +0 -13
  31. package/esm/plugins/meta-schema/constraint-meta-builders.js +0 -51
  32. package/esm/plugins/meta-schema/graphql-meta-field.d.ts +0 -4
  33. package/esm/plugins/meta-schema/graphql-meta-field.js +0 -201
  34. package/esm/plugins/meta-schema/inflection-utils.d.ts +0 -4
  35. package/esm/plugins/meta-schema/inflection-utils.js +0 -20
  36. package/esm/plugins/meta-schema/name-meta-builders.d.ts +0 -4
  37. package/esm/plugins/meta-schema/name-meta-builders.js +0 -38
  38. package/esm/plugins/meta-schema/plugin.d.ts +0 -2
  39. package/esm/plugins/meta-schema/plugin.js +0 -23
  40. package/esm/plugins/meta-schema/relation-meta-builders.d.ts +0 -8
  41. package/esm/plugins/meta-schema/relation-meta-builders.js +0 -115
  42. package/esm/plugins/meta-schema/table-meta-builder.d.ts +0 -2
  43. package/esm/plugins/meta-schema/table-meta-builder.js +0 -69
  44. package/esm/plugins/meta-schema/table-meta-context.d.ts +0 -13
  45. package/esm/plugins/meta-schema/table-meta-context.js +0 -11
  46. package/esm/plugins/meta-schema/table-resource-utils.d.ts +0 -12
  47. package/esm/plugins/meta-schema/table-resource-utils.js +0 -50
  48. package/esm/plugins/meta-schema/type-mappings.d.ts +0 -3
  49. package/esm/plugins/meta-schema/type-mappings.js +0 -75
  50. package/esm/plugins/meta-schema/types.d.ts +0 -206
  51. package/esm/plugins/meta-schema/types.js +0 -1
  52. package/esm/plugins/meta-schema.d.ts +0 -19
  53. package/esm/plugins/meta-schema.js +0 -20
  54. package/esm/plugins/minimal-preset.d.ts +0 -7
  55. package/esm/plugins/minimal-preset.js +0 -42
  56. package/esm/plugins/pg-type-mappings.d.ts +0 -41
  57. package/esm/plugins/pg-type-mappings.js +0 -122
  58. package/esm/plugins/primary-key-only.d.ts +0 -96
  59. package/esm/plugins/primary-key-only.js +0 -143
  60. package/plugins/conflict-detector.d.ts +0 -7
  61. package/plugins/conflict-detector.js +0 -70
  62. package/plugins/custom-inflector.d.ts +0 -9
  63. package/plugins/custom-inflector.js +0 -385
  64. package/plugins/enable-all-filter-columns.d.ts +0 -60
  65. package/plugins/enable-all-filter-columns.js +0 -88
  66. package/plugins/inflector-logger.d.ts +0 -7
  67. package/plugins/inflector-logger.js +0 -218
  68. package/plugins/many-to-many-preset.d.ts +0 -62
  69. package/plugins/many-to-many-preset.js +0 -89
  70. package/plugins/meta-schema/cache.d.ts +0 -4
  71. package/plugins/meta-schema/cache.js +0 -12
  72. package/plugins/meta-schema/constraint-meta-builders.d.ts +0 -13
  73. package/plugins/meta-schema/constraint-meta-builders.js +0 -58
  74. package/plugins/meta-schema/graphql-meta-field.d.ts +0 -4
  75. package/plugins/meta-schema/graphql-meta-field.js +0 -204
  76. package/plugins/meta-schema/inflection-utils.d.ts +0 -4
  77. package/plugins/meta-schema/inflection-utils.js +0 -25
  78. package/plugins/meta-schema/name-meta-builders.d.ts +0 -4
  79. package/plugins/meta-schema/name-meta-builders.js +0 -43
  80. package/plugins/meta-schema/plugin.d.ts +0 -2
  81. package/plugins/meta-schema/plugin.js +0 -26
  82. package/plugins/meta-schema/relation-meta-builders.d.ts +0 -8
  83. package/plugins/meta-schema/relation-meta-builders.js +0 -120
  84. package/plugins/meta-schema/table-meta-builder.d.ts +0 -2
  85. package/plugins/meta-schema/table-meta-builder.js +0 -72
  86. package/plugins/meta-schema/table-meta-context.d.ts +0 -13
  87. package/plugins/meta-schema/table-meta-context.js +0 -15
  88. package/plugins/meta-schema/table-resource-utils.d.ts +0 -12
  89. package/plugins/meta-schema/table-resource-utils.js +0 -60
  90. package/plugins/meta-schema/type-mappings.d.ts +0 -3
  91. package/plugins/meta-schema/type-mappings.js +0 -79
  92. package/plugins/meta-schema/types.d.ts +0 -206
  93. package/plugins/meta-schema/types.js +0 -2
  94. package/plugins/meta-schema.d.ts +0 -19
  95. package/plugins/meta-schema.js +0 -20
  96. package/plugins/minimal-preset.d.ts +0 -7
  97. package/plugins/minimal-preset.js +0 -45
  98. package/plugins/pg-type-mappings.d.ts +0 -41
  99. package/plugins/pg-type-mappings.js +0 -128
  100. package/plugins/primary-key-only.d.ts +0 -96
  101. package/plugins/primary-key-only.js +0 -147
@@ -1,147 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NoUniqueLookupPreset = exports.PrimaryKeyOnlyPreset = exports.NoUniqueLookupPlugin = exports.PrimaryKeyOnlyPlugin = void 0;
4
- exports.createUniqueLookupPlugin = createUniqueLookupPlugin;
5
- /**
6
- * PrimaryKeyOnlyPlugin - Disables non-primary-key unique constraint lookups for
7
- * BOTH queries AND mutations.
8
- *
9
- * WHY THIS EXISTS:
10
- * PostGraphile v5 creates fields for EVERY unique constraint on a table:
11
- *
12
- * QUERIES (PgRowByUniquePlugin):
13
- * - `user(id)`, `userByEmail(email)`, `userByUsername(username)`
14
- *
15
- * MUTATIONS (PgMutationUpdateDeletePlugin):
16
- * - `updateUser`, `updateUserByEmail`, `updateUserByUsername`
17
- * - `deleteUser`, `deleteUserByEmail`, `deleteUserByUsername`
18
- *
19
- * For code generation (React Query, etc.), this creates unnecessary complexity.
20
- * The same operations can be done using the primary key lookup or filters.
21
- * Standardizing on primary keys reduces the API surface and generated code.
22
- *
23
- * SOURCE CODE REFERENCES:
24
- *
25
- * 1. Query fields (PgRowByUniquePlugin):
26
- * https://github.com/graphile/crystal/blob/924b2515c6bd30e5905ac1419a25244b40c8bb4d/graphile-build/graphile-build-pg/src/plugins/PgRowByUniquePlugin.ts#L42-L257
27
- *
28
- * The behavior check for queries:
29
- * ```typescript
30
- * const fieldBehaviorScope = "query:resource:single";
31
- * if (!build.behavior.pgResourceUniqueMatches([resource, unique], fieldBehaviorScope)) {
32
- * return memo; // Skip this field
33
- * }
34
- * ```
35
- *
36
- * 2. Mutation fields (PgMutationUpdateDeletePlugin):
37
- * https://github.com/graphile/crystal/blob/924b2515c6bd30e5905ac1419a25244b40c8bb4d/graphile-build/graphile-build-pg/src/plugins/PgMutationUpdateDeletePlugin.ts
38
- *
39
- * The behavior check for mutations:
40
- * ```typescript
41
- * const constraintMode = `constraint:${mode}`; // "constraint:resource:update" or "constraint:resource:delete"
42
- * ...resource.uniques.filter((unique) => {
43
- * return build.behavior.pgResourceUniqueMatches([resource, unique], constraintMode);
44
- * })
45
- * ```
46
- *
47
- * OUR FIX:
48
- * We use the behavior system's OVERRIDE phase (not inferred) to disable these behaviors.
49
- * The override phase runs AFTER the behavior multiplication/preferences system processes
50
- * behaviors, giving us the final say on what's enabled/disabled.
51
- *
52
- * Behaviors we control:
53
- * - `-single` - Disables query lookups (userByEmail, etc.)
54
- * - `-constraint:resource:update` - Disables updateByX mutations
55
- * - `-constraint:resource:delete` - Disables deleteByX mutations
56
- *
57
- * CONFIGURATION OPTIONS:
58
- *
59
- * 1. `disableAllUniqueLookups: false` (default - PrimaryKeyOnlyPreset):
60
- * - Primary key: query lookup + mutations enabled
61
- * - Non-primary-key: everything disabled
62
- * Result: `user(id)`, `updateUser`, `deleteUser` only
63
- *
64
- * 2. `disableAllUniqueLookups: true` (NoUniqueLookupPreset):
65
- * - Primary key: query lookup DISABLED, mutations ENABLED
66
- * - Non-primary-key: everything disabled
67
- * Result: No query lookups (use filters), but `updateUser`, `deleteUser` still work
68
- */
69
- /**
70
- * Creates a plugin that controls unique constraint lookup behavior.
71
- *
72
- * @param options - Configuration options
73
- * @param options.disableAllUniqueLookups - If true, disables ALL unique lookups including primary keys
74
- */
75
- function createUniqueLookupPlugin(options = {}) {
76
- const { disableAllUniqueLookups = false } = options;
77
- return {
78
- name: 'UniqueLookupPlugin',
79
- version: '1.0.0',
80
- description: disableAllUniqueLookups
81
- ? 'Disables all unique constraint lookups (use filters instead)'
82
- : 'Disables non-primary-key unique constraint lookups to reduce API surface',
83
- schema: {
84
- entityBehavior: {
85
- pgResourceUnique: {
86
- // Use 'override' phase instead of 'inferred' - override runs AFTER
87
- // the behavior multiplication/preferences system processes behaviors,
88
- // so it has the final say on what behaviors are enabled/disabled.
89
- override: {
90
- provides: ['uniqueLookupControl'],
91
- callback(behavior, [_resource, unique]) {
92
- if (disableAllUniqueLookups) {
93
- // Disable ALL unique QUERY lookups - users must use filters
94
- // But KEEP primary key mutations (updateX, deleteX)
95
- if (unique.isPrimary) {
96
- // Primary key: only disable query lookups, keep mutations
97
- return [behavior, '-single'];
98
- }
99
- // Non-primary-key: disable everything (queries and mutations)
100
- return [
101
- behavior,
102
- '-single',
103
- '-constraint:resource:update',
104
- '-constraint:resource:delete',
105
- ];
106
- }
107
- // Only allow primary key lookups (both queries and mutations)
108
- if (!unique.isPrimary) {
109
- // Disable non-primary-key unique constraint lookups for queries and mutations
110
- return [
111
- behavior,
112
- '-single',
113
- '-constraint:resource:update',
114
- '-constraint:resource:delete',
115
- ];
116
- }
117
- return behavior;
118
- },
119
- },
120
- },
121
- },
122
- },
123
- };
124
- }
125
- // Default plugin instance (primary key only)
126
- exports.PrimaryKeyOnlyPlugin = createUniqueLookupPlugin({
127
- disableAllUniqueLookups: false,
128
- });
129
- // Plugin that disables ALL unique lookups
130
- exports.NoUniqueLookupPlugin = createUniqueLookupPlugin({
131
- disableAllUniqueLookups: true,
132
- });
133
- /**
134
- * Preset that keeps only primary key lookups.
135
- * Use this in your main preset's `extends` array.
136
- */
137
- exports.PrimaryKeyOnlyPreset = {
138
- plugins: [exports.PrimaryKeyOnlyPlugin],
139
- };
140
- /**
141
- * Preset that disables ALL unique lookups (including primary keys).
142
- * Users must use collection queries with filters instead.
143
- * Use this in your main preset's `extends` array.
144
- */
145
- exports.NoUniqueLookupPreset = {
146
- plugins: [exports.NoUniqueLookupPlugin],
147
- };