@strapi/typescript-utils 5.0.0-beta.0 → 5.0.0-beta.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.
@@ -48,7 +48,7 @@ describe('Attributes', () => {
48
48
 
49
49
  expect(prop.type.types).toHaveLength(1);
50
50
  expect(prop.type.types[0].kind).toBe(ts.SyntaxKind.TypeReference);
51
- expect(prop.type.types[0].typeName.escapedText).toBe('Attribute.String');
51
+ expect(prop.type.types[0].typeName.escapedText).toBe('Schema.Attribute.String');
52
52
  expect(prop.type.types[0].typeArguments).toBeUndefined();
53
53
  });
54
54
 
@@ -60,7 +60,7 @@ describe('Attributes', () => {
60
60
 
61
61
  expect(prop.type.types).toHaveLength(1);
62
62
  expect(prop.type.types[0].kind).toBe(ts.SyntaxKind.TypeReference);
63
- expect(prop.type.types[0].typeName.escapedText).toBe('Attribute.Component');
63
+ expect(prop.type.types[0].typeName.escapedText).toBe('Schema.Attribute.Component');
64
64
  expect(prop.type.types[0].typeArguments).toHaveLength(2);
65
65
  expect(prop.type.types[0].typeArguments[0].kind).toBe(ts.SyntaxKind.StringLiteral);
66
66
  expect(prop.type.types[0].typeArguments[0].text).toBe('default.comp');
@@ -83,14 +83,14 @@ describe('Attributes', () => {
83
83
  const [attributeType, requiredOptionType] = prop.type.types;
84
84
 
85
85
  expect(attributeType.kind).toBe(ts.SyntaxKind.TypeReference);
86
- expect(attributeType.typeName.escapedText).toBe('Attribute.Enumeration');
86
+ expect(attributeType.typeName.escapedText).toBe('Schema.Attribute.Enumeration');
87
87
  expect(attributeType.typeArguments).toHaveLength(1);
88
88
  expect(attributeType.typeArguments[0].kind).toBe(ts.SyntaxKind.TupleType);
89
89
  expect(attributeType.typeArguments[0].elements[0].text).toBe('a');
90
90
  expect(attributeType.typeArguments[0].elements[1].text).toBe('b');
91
91
 
92
92
  expect(requiredOptionType.kind).toBe(ts.SyntaxKind.TypeReference);
93
- expect(requiredOptionType.typeName.escapedText).toBe('Attribute.DefaultTo');
93
+ expect(requiredOptionType.typeName.escapedText).toBe('Schema.Attribute.DefaultTo');
94
94
  expect(requiredOptionType.typeArguments).toHaveLength(1);
95
95
  expect(requiredOptionType.typeArguments[0].kind).toBe(ts.SyntaxKind.StringLiteral);
96
96
  expect(requiredOptionType.typeArguments[0].text).toBe('b');
@@ -109,22 +109,22 @@ describe('Attributes', () => {
109
109
  });
110
110
 
111
111
  test.each([
112
- ['string', 'Attribute.String'],
113
- ['text', 'Attribute.Text'],
114
- ['richtext', 'Attribute.RichText'],
115
- ['password', 'Attribute.Password'],
116
- ['email', 'Attribute.Email'],
117
- ['date', 'Attribute.Date'],
118
- ['time', 'Attribute.Time'],
119
- ['datetime', 'Attribute.DateTime'],
120
- ['timestamp', 'Attribute.Timestamp'],
121
- ['integer', 'Attribute.Integer'],
122
- ['biginteger', 'Attribute.BigInteger'],
123
- ['float', 'Attribute.Float'],
124
- ['decimal', 'Attribute.Decimal'],
125
- ['boolean', 'Attribute.Boolean'],
126
- ['json', 'Attribute.JSON'],
127
- ['media', 'Attribute.Media'],
112
+ ['string', 'Schema.Attribute.String'],
113
+ ['text', 'Schema.Attribute.Text'],
114
+ ['richtext', 'Schema.Attribute.RichText'],
115
+ ['password', 'Schema.Attribute.Password'],
116
+ ['email', 'Schema.Attribute.Email'],
117
+ ['date', 'Schema.Attribute.Date'],
118
+ ['time', 'Schema.Attribute.Time'],
119
+ ['datetime', 'Schema.Attribute.DateTime'],
120
+ ['timestamp', 'Schema.Attribute.Timestamp'],
121
+ ['integer', 'Schema.Attribute.Integer'],
122
+ ['biginteger', 'Schema.Attribute.BigInteger'],
123
+ ['float', 'Schema.Attribute.Float'],
124
+ ['decimal', 'Schema.Attribute.Decimal'],
125
+ ['boolean', 'Schema.Attribute.Boolean'],
126
+ ['json', 'Schema.Attribute.JSON'],
127
+ ['media', 'Schema.Attribute.Media'],
128
128
  ])('Basic %p attribute should map to a %p type', (type, expectedType) => {
129
129
  const typeNode = getAttributeType('foo', { type });
130
130
 
@@ -135,7 +135,7 @@ describe('Attributes', () => {
135
135
  expect(typeNode.typeArguments).toBeUndefined();
136
136
 
137
137
  expect(consoleWarnMock).not.toHaveBeenCalled();
138
- expect(addImport).toHaveBeenCalledWith('Attribute');
138
+ expect(addImport).toHaveBeenCalledWith('Schema');
139
139
  });
140
140
 
141
141
  describe('Complex types (with generic type parameters)', () => {
@@ -146,7 +146,7 @@ describe('Attributes', () => {
146
146
  expect(typeNode.typeName.escapedText).toBe(typeName);
147
147
 
148
148
  expect(consoleWarnMock).not.toHaveBeenCalled();
149
- expect(addImport).toHaveBeenCalledWith('Attribute');
149
+ expect(addImport).toHaveBeenCalledWith('Schema');
150
150
  };
151
151
 
152
152
  describe('Enumeration', () => {
@@ -154,7 +154,7 @@ describe('Attributes', () => {
154
154
  const attribute = { type: 'enumeration', enum: ['a', 'b', 'c'] };
155
155
  const typeNode = getAttributeType('foo', attribute);
156
156
 
157
- defaultAssertions(typeNode, 'Attribute.Enumeration');
157
+ defaultAssertions(typeNode, 'Schema.Attribute.Enumeration');
158
158
 
159
159
  expect(typeNode.typeArguments).toHaveLength(1);
160
160
  expect(typeNode.typeArguments[0].kind).toBe(ts.SyntaxKind.TupleType);
@@ -175,7 +175,7 @@ describe('Attributes', () => {
175
175
  const attribute = { type: 'uid' };
176
176
  const typeNode = getAttributeType('foo', attribute);
177
177
 
178
- defaultAssertions(typeNode, 'Attribute.UID');
178
+ defaultAssertions(typeNode, 'Schema.Attribute.UID');
179
179
 
180
180
  expect(typeNode.typeArguments).toBeUndefined();
181
181
  });
@@ -184,7 +184,7 @@ describe('Attributes', () => {
184
184
  const attribute = { type: 'uid', targetField: 'bar' };
185
185
  const typeNode = getAttributeType('foo', attribute, 'api::bar.bar');
186
186
 
187
- defaultAssertions(typeNode, 'Attribute.UID');
187
+ defaultAssertions(typeNode, 'Schema.Attribute.UID');
188
188
 
189
189
  expect(typeNode.typeArguments).not.toBeUndefined();
190
190
  expect(typeNode.typeArguments).toHaveLength(1);
@@ -197,7 +197,7 @@ describe('Attributes', () => {
197
197
  const attribute = { type: 'uid', options: { separator: '_' } };
198
198
  const typeNode = getAttributeType('foo', attribute, 'api::foo.foo');
199
199
 
200
- defaultAssertions(typeNode, 'Attribute.UID');
200
+ defaultAssertions(typeNode, 'Schema.Attribute.UID');
201
201
 
202
202
  expect(typeNode.typeArguments).toHaveLength(2);
203
203
 
@@ -221,7 +221,7 @@ describe('Attributes', () => {
221
221
  const attribute = { type: 'uid', options: { separator: '_' }, targetField: 'bar' };
222
222
  const typeNode = getAttributeType('foo', attribute, 'api::bar.bar');
223
223
 
224
- defaultAssertions(typeNode, 'Attribute.UID');
224
+ defaultAssertions(typeNode, 'Schema.Attribute.UID');
225
225
 
226
226
  expect(typeNode.typeArguments).toHaveLength(2);
227
227
 
@@ -248,7 +248,7 @@ describe('Attributes', () => {
248
248
  const attribute = { type: 'relation', relation: 'oneToOne', target: 'api::bar.bar' };
249
249
  const typeNode = getAttributeType('foo', attribute, 'api::foo.foo');
250
250
 
251
- defaultAssertions(typeNode, 'Attribute.Relation');
251
+ defaultAssertions(typeNode, 'Schema.Attribute.Relation');
252
252
 
253
253
  expect(typeNode.typeArguments).toHaveLength(2);
254
254
 
@@ -263,7 +263,7 @@ describe('Attributes', () => {
263
263
  const attribute = { type: 'relation', relation: 'morphMany' };
264
264
  const typeNode = getAttributeType('foo', attribute, 'api::foo.foo');
265
265
 
266
- defaultAssertions(typeNode, 'Attribute.Relation');
266
+ defaultAssertions(typeNode, 'Schema.Attribute.Relation');
267
267
 
268
268
  expect(typeNode.typeArguments).toHaveLength(1);
269
269
 
@@ -277,7 +277,7 @@ describe('Attributes', () => {
277
277
  const attribute = { type: 'component', component: 'default.comp', repeatable: true };
278
278
  const typeNode = getAttributeType('foo', attribute);
279
279
 
280
- defaultAssertions(typeNode, 'Attribute.Component');
280
+ defaultAssertions(typeNode, 'Schema.Attribute.Component');
281
281
 
282
282
  expect(typeNode.typeArguments).toHaveLength(2);
283
283
 
@@ -291,7 +291,7 @@ describe('Attributes', () => {
291
291
  const attribute = { type: 'component', component: 'default.comp' };
292
292
  const typeNode = getAttributeType('foo', attribute);
293
293
 
294
- defaultAssertions(typeNode, 'Attribute.Component');
294
+ defaultAssertions(typeNode, 'Schema.Attribute.Component');
295
295
 
296
296
  expect(typeNode.typeArguments).toHaveLength(2);
297
297
 
@@ -307,7 +307,7 @@ describe('Attributes', () => {
307
307
  const attribute = { type: 'dynamiczone', components: ['default.comp1', 'default.comp2'] };
308
308
  const typeNode = getAttributeType('foo', attribute);
309
309
 
310
- defaultAssertions(typeNode, 'Attribute.DynamicZone');
310
+ defaultAssertions(typeNode, 'Schema.Attribute.DynamicZone');
311
311
 
312
312
  expect(typeNode.typeArguments).toHaveLength(1);
313
313
 
@@ -349,7 +349,7 @@ describe('Attributes', () => {
349
349
 
350
350
  expect(modifiers).toHaveLength(1);
351
351
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
352
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.Required');
352
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.Required');
353
353
  });
354
354
  });
355
355
 
@@ -374,7 +374,7 @@ describe('Attributes', () => {
374
374
 
375
375
  expect(modifiers).toHaveLength(1);
376
376
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
377
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.Private');
377
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.Private');
378
378
  });
379
379
  });
380
380
 
@@ -399,7 +399,7 @@ describe('Attributes', () => {
399
399
 
400
400
  expect(modifiers).toHaveLength(1);
401
401
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
402
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.Unique');
402
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.Unique');
403
403
  });
404
404
  });
405
405
 
@@ -424,7 +424,7 @@ describe('Attributes', () => {
424
424
 
425
425
  expect(modifiers).toHaveLength(1);
426
426
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
427
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.Configurable');
427
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.Configurable');
428
428
  });
429
429
  });
430
430
 
@@ -445,7 +445,7 @@ describe('Attributes', () => {
445
445
 
446
446
  expect(modifiers).toHaveLength(1);
447
447
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
448
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.CustomField');
448
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.CustomField');
449
449
  expect(modifiers[0].typeArguments).toHaveLength(1);
450
450
  expect(modifiers[0].typeArguments[0].kind).toBe(ts.SyntaxKind.StringLiteral);
451
451
  expect(modifiers[0].typeArguments[0].text).toBe('plugin::color-picker.color');
@@ -463,7 +463,7 @@ describe('Attributes', () => {
463
463
 
464
464
  expect(modifiers).toHaveLength(1);
465
465
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
466
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.CustomField');
466
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.CustomField');
467
467
  expect(modifiers[0].typeArguments).toHaveLength(2);
468
468
  expect(modifiers[0].typeArguments[0].kind).toBe(ts.SyntaxKind.StringLiteral);
469
469
  expect(modifiers[0].typeArguments[0].text).toBe('plugin::color-picker.color');
@@ -497,7 +497,7 @@ describe('Attributes', () => {
497
497
 
498
498
  expect(modifiers).toHaveLength(1);
499
499
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
500
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.SetPluginOptions');
500
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.SetPluginOptions');
501
501
  expect(modifiers[0].typeArguments).toHaveLength(1);
502
502
  expect(modifiers[0].typeArguments[0].kind).toBe(ts.SyntaxKind.TypeLiteral);
503
503
  expect(modifiers[0].typeArguments[0].members).toHaveLength(1);
@@ -536,7 +536,7 @@ describe('Attributes', () => {
536
536
  expect(modifiers).toHaveLength(1);
537
537
 
538
538
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
539
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.SetMinMax');
539
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.SetMinMax');
540
540
 
541
541
  const [setMinMax] = modifiers;
542
542
  const { typeArguments } = setMinMax;
@@ -568,7 +568,7 @@ describe('Attributes', () => {
568
568
  expect(modifiers).toHaveLength(1);
569
569
 
570
570
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
571
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.SetMinMax');
571
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.SetMinMax');
572
572
 
573
573
  const [setMinMax] = modifiers;
574
574
  const { typeArguments } = setMinMax;
@@ -600,7 +600,7 @@ describe('Attributes', () => {
600
600
  expect(modifiers).toHaveLength(1);
601
601
 
602
602
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
603
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.SetMinMax');
603
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.SetMinMax');
604
604
 
605
605
  const [setMinMax] = modifiers;
606
606
  const { typeArguments } = setMinMax;
@@ -637,7 +637,7 @@ describe('Attributes', () => {
637
637
  expect(modifiers).toHaveLength(1);
638
638
 
639
639
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
640
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.SetMinMax');
640
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.SetMinMax');
641
641
 
642
642
  const [setMinMax] = modifiers;
643
643
  const { typeArguments } = setMinMax;
@@ -669,7 +669,7 @@ describe('Attributes', () => {
669
669
  expect(modifiers).toHaveLength(1);
670
670
 
671
671
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
672
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.SetMinMax');
672
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.SetMinMax');
673
673
 
674
674
  const [setMinMax] = modifiers;
675
675
  const { typeArguments } = setMinMax;
@@ -710,7 +710,7 @@ describe('Attributes', () => {
710
710
  expect(modifiers).toHaveLength(1);
711
711
 
712
712
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
713
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.SetMinMaxLength');
713
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.SetMinMaxLength');
714
714
 
715
715
  expect(modifiers[0].typeArguments).toHaveLength(1);
716
716
  expect(modifiers[0].typeArguments[0].kind).toBe(ts.SyntaxKind.TypeLiteral);
@@ -734,7 +734,7 @@ describe('Attributes', () => {
734
734
  expect(modifiers).toHaveLength(1);
735
735
 
736
736
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
737
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.SetMinMaxLength');
737
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.SetMinMaxLength');
738
738
 
739
739
  expect(modifiers[0].typeArguments).toHaveLength(1);
740
740
  expect(modifiers[0].typeArguments[0].kind).toBe(ts.SyntaxKind.TypeLiteral);
@@ -758,7 +758,7 @@ describe('Attributes', () => {
758
758
  expect(modifiers).toHaveLength(1);
759
759
 
760
760
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
761
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.SetMinMaxLength');
761
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.SetMinMaxLength');
762
762
 
763
763
  expect(modifiers[0].typeArguments).toHaveLength(1);
764
764
  expect(modifiers[0].typeArguments[0].kind).toBe(ts.SyntaxKind.TypeLiteral);
@@ -800,7 +800,7 @@ describe('Attributes', () => {
800
800
  expect(modifiers).toHaveLength(1);
801
801
 
802
802
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
803
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.DefaultTo');
803
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.DefaultTo');
804
804
 
805
805
  expect(modifiers[0].typeArguments).toHaveLength(1);
806
806
  expect(modifiers[0].typeArguments[0].kind).toBe(ts.SyntaxKind.TrueKeyword);
@@ -813,7 +813,7 @@ describe('Attributes', () => {
813
813
  expect(modifiers).toHaveLength(1);
814
814
 
815
815
  expect(modifiers[0].kind).toBe(ts.SyntaxKind.TypeReference);
816
- expect(modifiers[0].typeName.escapedText).toBe('Attribute.DefaultTo');
816
+ expect(modifiers[0].typeName.escapedText).toBe('Schema.Attribute.DefaultTo');
817
817
 
818
818
  expect(modifiers[0].typeArguments).toHaveLength(1);
819
819
  expect(modifiers[0].typeArguments[0].kind).toBe(ts.SyntaxKind.TypeLiteral);
@@ -120,9 +120,9 @@ describe('Utils', () => {
120
120
 
121
121
  describe('Get Schema Extends Type Name', () => {
122
122
  test.each([
123
- [{ modelType: 'component', kind: null }, 'Schema.Component'],
124
- [{ modelType: 'contentType', kind: 'singleType' }, 'Schema.SingleType'],
125
- [{ modelType: 'contentType', kind: 'collectionType' }, 'Schema.CollectionType'],
123
+ [{ modelType: 'component', kind: null }, 'Struct.ComponentSchema'],
124
+ [{ modelType: 'contentType', kind: 'singleType' }, 'Struct.SingleTypeSchema'],
125
+ [{ modelType: 'contentType', kind: 'collectionType' }, 'Struct.CollectionTypeSchema'],
126
126
  [{ modelType: 'invalidType', kind: 'foo' }, null],
127
127
  ])("Expect %p to generate %p as the base type for a schema's interface", (schema, expected) => {
128
128
  expect(getSchemaExtendsTypeName(schema)).toBe(expected);
@@ -28,8 +28,8 @@ const getAttributeType = (attributeName, attribute, uid) => {
28
28
 
29
29
  const [attributeType, typeParams] = mappers[attribute.type]({ uid, attribute, attributeName });
30
30
 
31
- // Make sure the attribute namespace is imported
32
- addImport(NAMESPACES.attribute);
31
+ // Make sure the schema namespace is imported
32
+ addImport(NAMESPACES.Schema);
33
33
 
34
34
  return getTypeNode(attributeType, typeParams);
35
35
  };
@@ -195,6 +195,4 @@ const attributeToPropertySignature = (schema, attributeName, attribute) => {
195
195
 
196
196
  module.exports = attributeToPropertySignature;
197
197
 
198
- module.exports.mappers = mappers;
199
- module.exports.getAttributeType = getAttributeType;
200
- module.exports.getAttributeModifiers = getAttributeModifiers;
198
+ Object.assign(module.exports, { mappers, getAttributeModifiers, getAttributeType });
@@ -56,8 +56,8 @@ const generateSchemaDefinition = (schema) => {
56
56
  const interfaceName = getSchemaInterfaceName(uid);
57
57
  const parentType = getSchemaExtendsTypeName(schema);
58
58
 
59
- // Make sure the Schema namespace is imported
60
- addImport(NAMESPACES.schema);
59
+ // Make sure the Struct namespace is imported
60
+ addImport(NAMESPACES.Struct);
61
61
 
62
62
  // Properties whose values can be mapped to a literal type expression
63
63
  const literalPropertiesDefinitions = ['collectionName', 'info', 'options', 'pluginOptions']
@@ -18,8 +18,8 @@ const {
18
18
  } = require('lodash/fp');
19
19
 
20
20
  const NAMESPACES = {
21
- schema: 'Schema',
22
- attribute: 'Attribute',
21
+ Struct: 'Struct',
22
+ Schema: 'Schema',
23
23
  };
24
24
 
25
25
  /**
@@ -50,7 +50,7 @@ const getSchemaModelType = (schema) => {
50
50
  * Get the parent type name to extend based on the schema's nature
51
51
  *
52
52
  * @param {object} schema
53
- * @returns {string}
53
+ * @returns {string|null}
54
54
  */
55
55
  const getSchemaExtendsTypeName = (schema) => {
56
56
  const base = getSchemaModelType(schema);
@@ -59,7 +59,7 @@ const getSchemaExtendsTypeName = (schema) => {
59
59
  return null;
60
60
  }
61
61
 
62
- return `${NAMESPACES.schema}.${upperFirst(base)}`;
62
+ return `${NAMESPACES.Struct}.${upperFirst(base)}Schema`;
63
63
  };
64
64
 
65
65
  /**
@@ -145,12 +145,12 @@ const getDefinitionAttributesCount = (definition) => {
145
145
  };
146
146
 
147
147
  /**
148
- * Add the attribute namespace before the typename
148
+ * Add the Schema.Attribute namespace before the typename
149
149
  *
150
150
  * @param {string} typeName
151
151
  * @returns {string}
152
152
  */
153
- const withAttributeNamespace = (typeName) => `${NAMESPACES.attribute}.${typeName}`;
153
+ const withAttributeNamespace = (typeName) => `${NAMESPACES.Schema}.Attribute.${typeName}`;
154
154
 
155
155
  /**
156
156
  * Add the schema namespace before the typename
@@ -46,7 +46,7 @@ const generateComponentsDefinitions = async (options = {}) => {
46
46
  ...formattedSchemasDefinitions,
47
47
 
48
48
  // Global
49
- generateSharedExtensionDefinition('Components', componentsDefinitions),
49
+ generateSharedExtensionDefinition('ComponentSchemas', componentsDefinitions),
50
50
  ];
51
51
 
52
52
  const output = emitDefinitions(allDefinitions);
@@ -46,7 +46,7 @@ const generateContentTypesDefinitions = async (options = {}) => {
46
46
  ...formattedSchemasDefinitions,
47
47
 
48
48
  // Global
49
- generateSharedExtensionDefinition('ContentTypes', contentTypesDefinitions),
49
+ generateSharedExtensionDefinition('ContentTypeSchemas', contentTypesDefinitions),
50
50
  ];
51
51
 
52
52
  const output = emitDefinitions(allDefinitions);
@@ -100,7 +100,7 @@ const generate = async (config = {}) => {
100
100
 
101
101
  try {
102
102
  const outPath = await saveDefinitionToFileSystem(registryPwd, filename, report.output);
103
- const relativeOutPath = path.relative(__dirname, outPath);
103
+ const relativeOutPath = path.relative(process.cwd(), outPath);
104
104
 
105
105
  artifactFsTimer.end();
106
106
 
@@ -9,6 +9,9 @@ const chalk = require('chalk');
9
9
 
10
10
  const { factory } = ts;
11
11
 
12
+ const MODULE_DECLARATION = '@strapi/strapi';
13
+ const PUBLIC_NAMESPACE = 'Public';
14
+
12
15
  /**
13
16
  * Aggregate the given TypeScript nodes into a single string
14
17
  *
@@ -92,11 +95,11 @@ const generateSharedExtensionDefinition = (registry, definitions) => {
92
95
 
93
96
  return factory.createModuleDeclaration(
94
97
  [factory.createModifier(ts.SyntaxKind.DeclareKeyword)],
95
- factory.createStringLiteral('@strapi/types', true),
98
+ factory.createStringLiteral(MODULE_DECLARATION, true),
96
99
  factory.createModuleBlock([
97
100
  factory.createModuleDeclaration(
98
101
  [factory.createModifier(ts.SyntaxKind.ExportKeyword)],
99
- factory.createIdentifier('Shared'),
102
+ factory.createIdentifier(PUBLIC_NAMESPACE),
100
103
  factory.createModuleBlock(
101
104
  properties.length > 0
102
105
  ? [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/typescript-utils",
3
- "version": "5.0.0-beta.0",
3
+ "version": "5.0.0-beta.1",
4
4
  "description": "Typescript support for Strapi",
5
5
  "keywords": [
6
6
  "strapi",
@@ -46,5 +46,5 @@
46
46
  "node": ">=18.0.0 <=20.x.x",
47
47
  "npm": ">=6.0.0"
48
48
  },
49
- "gitHead": "4b2e592f77adbb0eacd7e3f15dd09e5cd3c46c22"
49
+ "gitHead": "ae773621dfcbc67c49dc6fa52ac41ea5de676ecb"
50
50
  }