@aws-amplify/datastore-storage-adapter 1.3.9-next.13 → 1.3.9-next.32

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 (49) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/lib/ExpoSQLiteAdapter/ExpoSQLiteAdapter.js +2 -4
  3. package/lib/ExpoSQLiteAdapter/ExpoSQLiteAdapter.js.map +1 -1
  4. package/lib/ExpoSQLiteAdapter/ExpoSQLiteDatabase.js +25 -80
  5. package/lib/ExpoSQLiteAdapter/ExpoSQLiteDatabase.js.map +1 -1
  6. package/lib/SQLiteAdapter/SQLiteAdapter.js +2 -4
  7. package/lib/SQLiteAdapter/SQLiteAdapter.js.map +1 -1
  8. package/lib/SQLiteAdapter/SQLiteDatabase.js +34 -99
  9. package/lib/SQLiteAdapter/SQLiteDatabase.js.map +1 -1
  10. package/lib/common/CommonSQLiteAdapter.js +36 -105
  11. package/lib/common/CommonSQLiteAdapter.js.map +1 -1
  12. package/lib/common/SQLiteUtils.js +28 -55
  13. package/lib/common/SQLiteUtils.js.map +1 -1
  14. package/lib/index.js +2 -4
  15. package/lib/index.js.map +1 -1
  16. package/lib-esm/ExpoSQLiteAdapter/ExpoSQLiteDatabase.js +1 -56
  17. package/lib-esm/ExpoSQLiteAdapter/ExpoSQLiteDatabase.js.map +1 -1
  18. package/lib-esm/SQLiteAdapter/SQLiteDatabase.js +1 -63
  19. package/lib-esm/SQLiteAdapter/SQLiteDatabase.js.map +1 -1
  20. package/lib-esm/common/CommonSQLiteAdapter.d.ts +3 -3
  21. package/lib-esm/common/CommonSQLiteAdapter.js +1 -70
  22. package/lib-esm/common/CommonSQLiteAdapter.js.map +1 -1
  23. package/lib-esm/common/SQLiteUtils.js +14 -41
  24. package/lib-esm/common/SQLiteUtils.js.map +1 -1
  25. package/lib-esm/common/types.d.ts +4 -1
  26. package/package.json +17 -5
  27. package/src/common/CommonSQLiteAdapter.ts +6 -3
  28. package/src/common/SQLiteUtils.ts +16 -10
  29. package/src/common/types.ts +6 -1
  30. package/build.js +0 -5
  31. package/dist/aws-amplify-datastore-sqlite-adapter-expo.js +0 -2506
  32. package/dist/aws-amplify-datastore-sqlite-adapter-expo.js.map +0 -1
  33. package/dist/aws-amplify-datastore-sqlite-adapter-expo.min.js +0 -2
  34. package/dist/aws-amplify-datastore-sqlite-adapter-expo.min.js.map +0 -1
  35. package/dist/aws-amplify-datastore-storage-adapter.js +0 -2460
  36. package/dist/aws-amplify-datastore-storage-adapter.js.map +0 -1
  37. package/dist/aws-amplify-datastore-storage-adapter.min.js +0 -2
  38. package/dist/aws-amplify-datastore-storage-adapter.min.js.map +0 -1
  39. package/index.js +0 -7
  40. package/lib/ExpoSQLiteAdapter/ExpoSQLiteAdapter.d.ts +0 -3
  41. package/lib/ExpoSQLiteAdapter/ExpoSQLiteDatabase.d.ts +0 -17
  42. package/lib/SQLiteAdapter/SQLiteAdapter.d.ts +0 -3
  43. package/lib/SQLiteAdapter/SQLiteDatabase.d.ts +0 -17
  44. package/lib/common/CommonSQLiteAdapter.d.ts +0 -23
  45. package/lib/common/SQLiteUtils.d.ts +0 -16
  46. package/lib/common/constants.d.ts +0 -1
  47. package/lib/common/types.d.ts +0 -13
  48. package/lib/index.d.ts +0 -2
  49. package/webpack.config.dev.js +0 -8
@@ -148,7 +148,7 @@ export function modelCreateTableStatement(
148
148
  let fields = Object.values(model.fields).reduce((acc, field: ModelField) => {
149
149
  if (isGraphQLScalarType(field.type)) {
150
150
  if (field.name === 'id') {
151
- return acc + '"id" PRIMARY KEY NOT NULL';
151
+ return [...acc, '"id" PRIMARY KEY NOT NULL'];
152
152
  }
153
153
 
154
154
  let columnParam = `"${field.name}" ${getSQLiteType(field.type)}`;
@@ -157,7 +157,7 @@ export function modelCreateTableStatement(
157
157
  columnParam += ' NOT NULL';
158
158
  }
159
159
 
160
- return acc + `, ${columnParam}`;
160
+ return [...acc, `${columnParam}`];
161
161
  }
162
162
 
163
163
  if (isModelFieldType(field.type)) {
@@ -167,7 +167,7 @@ export function modelCreateTableStatement(
167
167
  if (isTargetNameAssociation(field.association)) {
168
168
  // check if this field has been explicitly defined in the model
169
169
  const fkDefinedInModel = Object.values(model.fields).find(
170
- (f: ModelField) => f.name === field.association.targetName
170
+ (f: ModelField) => f.name === field?.association?.targetName
171
171
  );
172
172
 
173
173
  // if the FK is not explicitly defined in the model, we have to add it here
@@ -179,7 +179,7 @@ export function modelCreateTableStatement(
179
179
 
180
180
  // ignore isRequired param for model fields, since they will not contain
181
181
  // the related data locally
182
- return acc + `, ${columnParam}`;
182
+ return [...acc, `${columnParam}`];
183
183
  }
184
184
 
185
185
  // default to TEXT
@@ -189,19 +189,25 @@ export function modelCreateTableStatement(
189
189
  columnParam += ' NOT NULL';
190
190
  }
191
191
 
192
- return acc + `, ${columnParam}`;
193
- }, '');
192
+ return [...acc, `${columnParam}`];
193
+ }, [] as string[]);
194
194
 
195
195
  implicitAuthFields.forEach((authField: string) => {
196
- fields += `, ${authField} TEXT`;
196
+ fields.push(`${authField} TEXT`);
197
197
  });
198
198
 
199
199
  if (userModel) {
200
- fields +=
201
- ', "_version" INTEGER, "_lastChangedAt" INTEGER, "_deleted" INTEGER';
200
+ fields = [
201
+ ...fields,
202
+ `"_version" INTEGER`,
203
+ `"_lastChangedAt" INTEGER`,
204
+ `"_deleted" INTEGER`,
205
+ ];
202
206
  }
203
207
 
204
- const createTableStatement = `CREATE TABLE IF NOT EXISTS "${model.name}" (${fields});`;
208
+ const createTableStatement = `CREATE TABLE IF NOT EXISTS "${
209
+ model.name
210
+ }" (${fields.join(', ')});`;
205
211
  return createTableStatement;
206
212
  }
207
213
 
@@ -1,4 +1,4 @@
1
- import { PersistentModel } from '@aws-amplify/datastore';
1
+ import { PersistentModel, ModelInstanceMetadata } from '@aws-amplify/datastore';
2
2
 
3
3
  export interface CommonSQLiteDatabase {
4
4
  init(): Promise<void>;
@@ -27,3 +27,8 @@ export interface CommonSQLiteDatabase {
27
27
  }
28
28
 
29
29
  export type ParameterizedStatement = [string, any[]];
30
+
31
+ // TODO: remove once we implement CPK for this adapter
32
+ export type ModelInstanceMetadataWithId = ModelInstanceMetadata & {
33
+ id: string;
34
+ };
package/build.js DELETED
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- const build = require('../../scripts/build');
4
-
5
- build(process.argv[2], process.argv[3]);