@salesforce/lds-runtime-mobile 1.290.0 → 1.291.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.
package/dist/main.js CHANGED
@@ -9113,6 +9113,32 @@ async function readIngestionTimestampForKey(key, query) {
9113
9113
  return ingestionTimestamp;
9114
9114
  }
9115
9115
 
9116
+ // Code lifted from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
9117
+ // base64 character set, plus padding character (=)
9118
+ const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
9119
+ function btoaPolyfill(input) {
9120
+ let bitmap, a, b, c;
9121
+ let result = '', i = 0;
9122
+ const rest = input.length % 3; // To determine the final padding
9123
+ for (; i < input.length;) {
9124
+ if ((a = input.charCodeAt(i++)) > 255 ||
9125
+ (b = input.charCodeAt(i++)) > 255 ||
9126
+ (c = input.charCodeAt(i++)) > 255) {
9127
+ throw new TypeError('Failed base64ToAscii encoding: The string to be encoded contains characters outside of the Latin1 range. ' +
9128
+ input);
9129
+ }
9130
+ bitmap = (a << 16) | (b << 8) | c;
9131
+ result +=
9132
+ b64.charAt((bitmap >> 18) & 63) +
9133
+ b64.charAt((bitmap >> 12) & 63) +
9134
+ b64.charAt((bitmap >> 6) & 63) +
9135
+ b64.charAt(bitmap & 63);
9136
+ }
9137
+ // If there's need of padding, replace the last 'A's with equal signs
9138
+ return rest ? result.slice(0, rest - 3) + '==='.substring(rest) : result;
9139
+ }
9140
+ const base64encode = typeof btoa === 'function' ? btoa : btoaPolyfill;
9141
+
9116
9142
  function findSpanningField(name) {
9117
9143
  return (field) => {
9118
9144
  return (field.apiName === name ||
@@ -9394,6 +9420,11 @@ function addResolversToSchema(schema, polyFields) {
9394
9420
  return { recordRepresentation, ingestionTimestamp };
9395
9421
  };
9396
9422
  }
9423
+ else if (field.name === 'cursor') {
9424
+ field.resolve = function ({ index }) {
9425
+ return base64encode(`v1:${index}`);
9426
+ };
9427
+ }
9397
9428
  }
9398
9429
  }
9399
9430
  if (isRecordType(type)) {
@@ -9610,10 +9641,11 @@ async function connectionEdgeResolver(obj, _args, context) {
9610
9641
  //map each sql result with the ingestion timestamp to pass it down a level
9611
9642
  return results.rows
9612
9643
  .map((row) => row[0])
9613
- .map((record) => {
9644
+ .map((record, index) => {
9614
9645
  return {
9615
9646
  record,
9616
9647
  ingestionTimestamp,
9648
+ index,
9617
9649
  };
9618
9650
  });
9619
9651
  }
@@ -17907,6 +17939,20 @@ class SqlitePrimingStore {
17907
17939
  async writeBatch(records, overwrite) {
17908
17940
  const idsToPrime = new Set();
17909
17941
  const written = [];
17942
+ if (overwrite === true) {
17943
+ // if overwrite is true we need to raise change notifications so use the batchOperations
17944
+ const operations = {};
17945
+ for (const { record, metadata } of records) {
17946
+ const key = keyBuilderRecord(this.getLuvio(), { recordId: record.id });
17947
+ idsToPrime.add(record.id);
17948
+ operations[key] = {
17949
+ data: record,
17950
+ metadata: { ...metadata, metadataVersion: DURABLE_METADATA_VERSION },
17951
+ };
17952
+ }
17953
+ await this.store.setEntries(operations, DefaultDurableSegment);
17954
+ return { written: Array.from(idsToPrime), conflicted: [], errors: [] };
17955
+ }
17910
17956
  const statement = `${overwrite ? 'REPLACE' : 'INSERT or IGNORE'} INTO lds_data (key, data, metadata) VALUES ${records
17911
17957
  .map((_) => `(?,?,?)`)
17912
17958
  .join(',')} returning key;`;
@@ -18275,4 +18321,4 @@ register({
18275
18321
  });
18276
18322
 
18277
18323
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
18278
- // version: 1.290.0-18c27a6e9
18324
+ // version: 1.291.0-8df6969f6
@@ -1,10 +1,10 @@
1
1
  import type { PrimingStore, RecordWithMetadata, WriteResult } from '@salesforce/lds-priming';
2
2
  import type { Luvio } from '@luvio/engine';
3
- import type { SqliteStore } from '@salesforce/lds-store-sql';
3
+ import type { NimbusSqliteStore } from '@salesforce/lds-store-nimbus';
4
4
  export declare class SqlitePrimingStore implements PrimingStore {
5
5
  private readonly getLuvio;
6
6
  private readonly store;
7
- constructor(getLuvio: () => Luvio, store: SqliteStore);
7
+ constructor(getLuvio: () => Luvio, store: NimbusSqliteStore);
8
8
  readRecords(ids: string[]): Promise<RecordWithMetadata[]>;
9
9
  writeRecords(records: RecordWithMetadata[], overwrite: boolean): Promise<WriteResult>;
10
10
  private writeBatch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.290.0",
3
+ "version": "1.291.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS runtime for mobile/hybrid environments.",
6
6
  "main": "dist/main.js",
@@ -32,25 +32,25 @@
32
32
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-mobile"
33
33
  },
34
34
  "dependencies": {
35
- "@salesforce/lds-adapters-uiapi": "^1.290.0",
36
- "@salesforce/lds-bindings": "^1.290.0",
37
- "@salesforce/lds-instrumentation": "^1.290.0",
38
- "@salesforce/lds-priming": "^1.290.0",
35
+ "@salesforce/lds-adapters-uiapi": "^1.291.0",
36
+ "@salesforce/lds-bindings": "^1.291.0",
37
+ "@salesforce/lds-instrumentation": "^1.291.0",
38
+ "@salesforce/lds-priming": "^1.291.0",
39
39
  "@salesforce/user": "0.0.21",
40
40
  "o11y": "250.7.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@salesforce/lds-adapters-graphql": "^1.290.0",
44
- "@salesforce/lds-drafts": "^1.290.0",
45
- "@salesforce/lds-drafts-adapters-uiapi": "^1.290.0",
46
- "@salesforce/lds-graphql-eval": "^1.290.0",
47
- "@salesforce/lds-network-adapter": "^1.290.0",
48
- "@salesforce/lds-network-nimbus": "^1.290.0",
49
- "@salesforce/lds-store-binary": "^1.290.0",
50
- "@salesforce/lds-store-nimbus": "^1.290.0",
51
- "@salesforce/lds-store-sql": "^1.290.0",
52
- "@salesforce/lds-utils-adapters": "^1.290.0",
53
- "@salesforce/nimbus-plugin-lds": "^1.290.0",
43
+ "@salesforce/lds-adapters-graphql": "^1.291.0",
44
+ "@salesforce/lds-drafts": "^1.291.0",
45
+ "@salesforce/lds-drafts-adapters-uiapi": "^1.291.0",
46
+ "@salesforce/lds-graphql-eval": "^1.291.0",
47
+ "@salesforce/lds-network-adapter": "^1.291.0",
48
+ "@salesforce/lds-network-nimbus": "^1.291.0",
49
+ "@salesforce/lds-store-binary": "^1.291.0",
50
+ "@salesforce/lds-store-nimbus": "^1.291.0",
51
+ "@salesforce/lds-store-sql": "^1.291.0",
52
+ "@salesforce/lds-utils-adapters": "^1.291.0",
53
+ "@salesforce/nimbus-plugin-lds": "^1.291.0",
54
54
  "babel-plugin-dynamic-import-node": "^2.3.3",
55
55
  "wait-for-expect": "^3.0.2"
56
56
  },
@@ -59,7 +59,7 @@
59
59
  "path": "./dist/main.js",
60
60
  "maxSize": {
61
61
  "none": "800 kB",
62
- "min": "323.2 kB",
62
+ "min": "400 kB",
63
63
  "compressed": "150 kB"
64
64
  }
65
65
  },
@@ -67,7 +67,7 @@
67
67
  "path": "./sfdc/main.js",
68
68
  "maxSize": {
69
69
  "none": "800 kB",
70
- "min": "323.2 kB",
70
+ "min": "400 kB",
71
71
  "compressed": "150 kB"
72
72
  }
73
73
  }
package/sfdc/main.js CHANGED
@@ -9113,6 +9113,32 @@ async function readIngestionTimestampForKey(key, query) {
9113
9113
  return ingestionTimestamp;
9114
9114
  }
9115
9115
 
9116
+ // Code lifted from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
9117
+ // base64 character set, plus padding character (=)
9118
+ const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
9119
+ function btoaPolyfill(input) {
9120
+ let bitmap, a, b, c;
9121
+ let result = '', i = 0;
9122
+ const rest = input.length % 3; // To determine the final padding
9123
+ for (; i < input.length;) {
9124
+ if ((a = input.charCodeAt(i++)) > 255 ||
9125
+ (b = input.charCodeAt(i++)) > 255 ||
9126
+ (c = input.charCodeAt(i++)) > 255) {
9127
+ throw new TypeError('Failed base64ToAscii encoding: The string to be encoded contains characters outside of the Latin1 range. ' +
9128
+ input);
9129
+ }
9130
+ bitmap = (a << 16) | (b << 8) | c;
9131
+ result +=
9132
+ b64.charAt((bitmap >> 18) & 63) +
9133
+ b64.charAt((bitmap >> 12) & 63) +
9134
+ b64.charAt((bitmap >> 6) & 63) +
9135
+ b64.charAt(bitmap & 63);
9136
+ }
9137
+ // If there's need of padding, replace the last 'A's with equal signs
9138
+ return rest ? result.slice(0, rest - 3) + '==='.substring(rest) : result;
9139
+ }
9140
+ const base64encode = typeof btoa === 'function' ? btoa : btoaPolyfill;
9141
+
9116
9142
  function findSpanningField(name) {
9117
9143
  return (field) => {
9118
9144
  return (field.apiName === name ||
@@ -9394,6 +9420,11 @@ function addResolversToSchema(schema, polyFields) {
9394
9420
  return { recordRepresentation, ingestionTimestamp };
9395
9421
  };
9396
9422
  }
9423
+ else if (field.name === 'cursor') {
9424
+ field.resolve = function ({ index }) {
9425
+ return base64encode(`v1:${index}`);
9426
+ };
9427
+ }
9397
9428
  }
9398
9429
  }
9399
9430
  if (isRecordType(type)) {
@@ -9610,10 +9641,11 @@ async function connectionEdgeResolver(obj, _args, context) {
9610
9641
  //map each sql result with the ingestion timestamp to pass it down a level
9611
9642
  return results.rows
9612
9643
  .map((row) => row[0])
9613
- .map((record) => {
9644
+ .map((record, index) => {
9614
9645
  return {
9615
9646
  record,
9616
9647
  ingestionTimestamp,
9648
+ index,
9617
9649
  };
9618
9650
  });
9619
9651
  }
@@ -17907,6 +17939,20 @@ class SqlitePrimingStore {
17907
17939
  async writeBatch(records, overwrite) {
17908
17940
  const idsToPrime = new Set();
17909
17941
  const written = [];
17942
+ if (overwrite === true) {
17943
+ // if overwrite is true we need to raise change notifications so use the batchOperations
17944
+ const operations = {};
17945
+ for (const { record, metadata } of records) {
17946
+ const key = keyBuilderRecord(this.getLuvio(), { recordId: record.id });
17947
+ idsToPrime.add(record.id);
17948
+ operations[key] = {
17949
+ data: record,
17950
+ metadata: { ...metadata, metadataVersion: DURABLE_METADATA_VERSION },
17951
+ };
17952
+ }
17953
+ await this.store.setEntries(operations, DefaultDurableSegment);
17954
+ return { written: Array.from(idsToPrime), conflicted: [], errors: [] };
17955
+ }
17910
17956
  const statement = `${overwrite ? 'REPLACE' : 'INSERT or IGNORE'} INTO lds_data (key, data, metadata) VALUES ${records
17911
17957
  .map((_) => `(?,?,?)`)
17912
17958
  .join(',')} returning key;`;
@@ -18275,4 +18321,4 @@ register({
18275
18321
  });
18276
18322
 
18277
18323
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
18278
- // version: 1.290.0-18c27a6e9
18324
+ // version: 1.291.0-8df6969f6
@@ -1,10 +1,10 @@
1
1
  import type { PrimingStore, RecordWithMetadata, WriteResult } from '@salesforce/lds-priming';
2
2
  import type { Luvio } from '@luvio/engine';
3
- import type { SqliteStore } from '@salesforce/lds-store-sql';
3
+ import type { NimbusSqliteStore } from '@salesforce/lds-store-nimbus';
4
4
  export declare class SqlitePrimingStore implements PrimingStore {
5
5
  private readonly getLuvio;
6
6
  private readonly store;
7
- constructor(getLuvio: () => Luvio, store: SqliteStore);
7
+ constructor(getLuvio: () => Luvio, store: NimbusSqliteStore);
8
8
  readRecords(ids: string[]): Promise<RecordWithMetadata[]>;
9
9
  writeRecords(records: RecordWithMetadata[], overwrite: boolean): Promise<WriteResult>;
10
10
  private writeBatch;