@hot-updater/postgres 0.29.4 → 0.29.6

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/index.cjs CHANGED
@@ -1880,9 +1880,31 @@ const appVersionStrategy = async (pool, { platform, appVersion, bundleId, minBun
1880
1880
  ]);
1881
1881
  return result.rows[0] ? camelcaseKeys(result.rows[0]) : null;
1882
1882
  };
1883
+ const fingerprintStrategy = async (pool, { platform, fingerprintHash, bundleId, minBundleId = _hot_updater_core.NIL_UUID, channel = "production", cohort }) => {
1884
+ const sqlGetUpdateInfo = (0, import_lib.default)(`
1885
+ SELECT *
1886
+ FROM get_update_info_by_fingerprint_hash(
1887
+ $1, -- platform
1888
+ $2, -- bundleId
1889
+ $3, -- minBundleId (nullable)
1890
+ $4, -- channel
1891
+ $5, -- fingerprintHash
1892
+ $6 -- cohort (nullable)
1893
+ );
1894
+ `);
1895
+ const result = await pool.query(sqlGetUpdateInfo, [
1896
+ platform,
1897
+ bundleId,
1898
+ minBundleId ?? _hot_updater_core.NIL_UUID,
1899
+ channel,
1900
+ fingerprintHash,
1901
+ cohort ?? null
1902
+ ]);
1903
+ return result.rows[0] ? camelcaseKeys(result.rows[0]) : null;
1904
+ };
1883
1905
  const getUpdateInfo = (pool, args) => {
1884
1906
  if (args._updateStrategy === "appVersion") return appVersionStrategy(pool, args);
1885
- return null;
1907
+ return fingerprintStrategy(pool, args);
1886
1908
  };
1887
1909
  //#endregion
1888
1910
  //#region src/postgres.ts
@@ -1896,6 +1918,9 @@ const postgres = (0, _hot_updater_plugin_core.createDatabasePlugin)({
1896
1918
  await db.destroy();
1897
1919
  await pool.end();
1898
1920
  },
1921
+ async getUpdateInfo(args) {
1922
+ return getUpdateInfo(pool, args);
1923
+ },
1899
1924
  async getBundleById(bundleId) {
1900
1925
  const data = await db.selectFrom("bundles").selectAll().where("id", "=", bundleId).executeTakeFirst();
1901
1926
  if (!data) return null;
@@ -1914,7 +1939,8 @@ const postgres = (0, _hot_updater_plugin_core.createDatabasePlugin)({
1914
1939
  };
1915
1940
  },
1916
1941
  async getBundles(options) {
1917
- const { where, limit, offset, orderBy } = options ?? {};
1942
+ const { where, limit, orderBy } = options ?? {};
1943
+ const offset = (options && "offset" in options ? options.offset : void 0) ?? 0;
1918
1944
  let countQuery = db.selectFrom("bundles");
1919
1945
  if (where?.channel) countQuery = countQuery.where("channel", "=", where.channel);
1920
1946
  if (where?.platform) countQuery = countQuery.where("platform", "=", where.platform);
@@ -2008,5 +2034,6 @@ const postgres = (0, _hot_updater_plugin_core.createDatabasePlugin)({
2008
2034
  });
2009
2035
  //#endregion
2010
2036
  exports.appVersionStrategy = appVersionStrategy;
2037
+ exports.fingerprintStrategy = fingerprintStrategy;
2011
2038
  exports.getUpdateInfo = getUpdateInfo;
2012
2039
  exports.postgres = postgres;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { AppVersionGetBundlesArgs, GetBundlesArgs, UpdateInfo } from "@hot-updater/core";
1
+ import { AppVersionGetBundlesArgs, FingerprintGetBundlesArgs, GetBundlesArgs, UpdateInfo } from "@hot-updater/core";
2
2
  import pg, { PoolConfig } from "pg";
3
3
  import * as _$_hot_updater_plugin_core0 from "@hot-updater/plugin-core";
4
4
 
@@ -11,10 +11,18 @@ declare const appVersionStrategy: (pool: pg.Pool, {
11
11
  channel,
12
12
  cohort
13
13
  }: AppVersionGetBundlesArgs) => Promise<UpdateInfo | null>;
14
- declare const getUpdateInfo: (pool: pg.Pool, args: GetBundlesArgs) => Promise<UpdateInfo | null> | null;
14
+ declare const fingerprintStrategy: (pool: pg.Pool, {
15
+ platform,
16
+ fingerprintHash,
17
+ bundleId,
18
+ minBundleId,
19
+ channel,
20
+ cohort
21
+ }: FingerprintGetBundlesArgs) => Promise<UpdateInfo | null>;
22
+ declare const getUpdateInfo: (pool: pg.Pool, args: GetBundlesArgs) => Promise<UpdateInfo | null>;
15
23
  //#endregion
16
24
  //#region src/postgres.d.ts
17
25
  interface PostgresConfig extends PoolConfig {}
18
26
  declare const postgres: (config: PostgresConfig, hooks?: _$_hot_updater_plugin_core0.DatabasePluginHooks) => () => _$_hot_updater_plugin_core0.DatabasePlugin<unknown>;
19
27
  //#endregion
20
- export { PostgresConfig, appVersionStrategy, getUpdateInfo, postgres };
28
+ export { PostgresConfig, appVersionStrategy, fingerprintStrategy, getUpdateInfo, postgres };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { AppVersionGetBundlesArgs, GetBundlesArgs, UpdateInfo } from "@hot-updater/core";
1
+ import { AppVersionGetBundlesArgs, FingerprintGetBundlesArgs, GetBundlesArgs, UpdateInfo } from "@hot-updater/core";
2
2
  import * as _$_hot_updater_plugin_core0 from "@hot-updater/plugin-core";
3
3
  import pg, { PoolConfig } from "pg";
4
4
 
@@ -11,10 +11,18 @@ declare const appVersionStrategy: (pool: pg.Pool, {
11
11
  channel,
12
12
  cohort
13
13
  }: AppVersionGetBundlesArgs) => Promise<UpdateInfo | null>;
14
- declare const getUpdateInfo: (pool: pg.Pool, args: GetBundlesArgs) => Promise<UpdateInfo | null> | null;
14
+ declare const fingerprintStrategy: (pool: pg.Pool, {
15
+ platform,
16
+ fingerprintHash,
17
+ bundleId,
18
+ minBundleId,
19
+ channel,
20
+ cohort
21
+ }: FingerprintGetBundlesArgs) => Promise<UpdateInfo | null>;
22
+ declare const getUpdateInfo: (pool: pg.Pool, args: GetBundlesArgs) => Promise<UpdateInfo | null>;
15
23
  //#endregion
16
24
  //#region src/postgres.d.ts
17
25
  interface PostgresConfig extends PoolConfig {}
18
26
  declare const postgres: (config: PostgresConfig, hooks?: _$_hot_updater_plugin_core0.DatabasePluginHooks) => () => _$_hot_updater_plugin_core0.DatabasePlugin<unknown>;
19
27
  //#endregion
20
- export { PostgresConfig, appVersionStrategy, getUpdateInfo, postgres };
28
+ export { PostgresConfig, appVersionStrategy, fingerprintStrategy, getUpdateInfo, postgres };
package/dist/index.mjs CHANGED
@@ -1881,9 +1881,31 @@ const appVersionStrategy = async (pool, { platform, appVersion, bundleId, minBun
1881
1881
  ]);
1882
1882
  return result.rows[0] ? camelcaseKeys(result.rows[0]) : null;
1883
1883
  };
1884
+ const fingerprintStrategy = async (pool, { platform, fingerprintHash, bundleId, minBundleId = NIL_UUID, channel = "production", cohort }) => {
1885
+ const sqlGetUpdateInfo = (0, import_lib.default)(`
1886
+ SELECT *
1887
+ FROM get_update_info_by_fingerprint_hash(
1888
+ $1, -- platform
1889
+ $2, -- bundleId
1890
+ $3, -- minBundleId (nullable)
1891
+ $4, -- channel
1892
+ $5, -- fingerprintHash
1893
+ $6 -- cohort (nullable)
1894
+ );
1895
+ `);
1896
+ const result = await pool.query(sqlGetUpdateInfo, [
1897
+ platform,
1898
+ bundleId,
1899
+ minBundleId ?? NIL_UUID,
1900
+ channel,
1901
+ fingerprintHash,
1902
+ cohort ?? null
1903
+ ]);
1904
+ return result.rows[0] ? camelcaseKeys(result.rows[0]) : null;
1905
+ };
1884
1906
  const getUpdateInfo = (pool, args) => {
1885
1907
  if (args._updateStrategy === "appVersion") return appVersionStrategy(pool, args);
1886
- return null;
1908
+ return fingerprintStrategy(pool, args);
1887
1909
  };
1888
1910
  //#endregion
1889
1911
  //#region src/postgres.ts
@@ -1897,6 +1919,9 @@ const postgres = createDatabasePlugin({
1897
1919
  await db.destroy();
1898
1920
  await pool.end();
1899
1921
  },
1922
+ async getUpdateInfo(args) {
1923
+ return getUpdateInfo(pool, args);
1924
+ },
1900
1925
  async getBundleById(bundleId) {
1901
1926
  const data = await db.selectFrom("bundles").selectAll().where("id", "=", bundleId).executeTakeFirst();
1902
1927
  if (!data) return null;
@@ -1915,7 +1940,8 @@ const postgres = createDatabasePlugin({
1915
1940
  };
1916
1941
  },
1917
1942
  async getBundles(options) {
1918
- const { where, limit, offset, orderBy } = options ?? {};
1943
+ const { where, limit, orderBy } = options ?? {};
1944
+ const offset = (options && "offset" in options ? options.offset : void 0) ?? 0;
1919
1945
  let countQuery = db.selectFrom("bundles");
1920
1946
  if (where?.channel) countQuery = countQuery.where("channel", "=", where.channel);
1921
1947
  if (where?.platform) countQuery = countQuery.where("platform", "=", where.platform);
@@ -2008,4 +2034,4 @@ const postgres = createDatabasePlugin({
2008
2034
  }
2009
2035
  });
2010
2036
  //#endregion
2011
- export { appVersionStrategy, getUpdateInfo, postgres };
2037
+ export { appVersionStrategy, fingerprintStrategy, getUpdateInfo, postgres };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/postgres",
3
3
  "type": "module",
4
- "version": "0.29.4",
4
+ "version": "0.29.6",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.mjs",
@@ -31,8 +31,8 @@
31
31
  "dependencies": {
32
32
  "kysely": "^0.28.5",
33
33
  "pg": "^8.13.1",
34
- "@hot-updater/core": "0.29.4",
35
- "@hot-updater/plugin-core": "0.29.4"
34
+ "@hot-updater/core": "0.29.6",
35
+ "@hot-updater/plugin-core": "0.29.6"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@electric-sql/pglite": "^0.2.15",
@@ -40,8 +40,8 @@
40
40
  "@types/pg": "^8.11.10",
41
41
  "camelcase-keys": "^9.1.3",
42
42
  "pg-minify": "^1.6.5",
43
- "@hot-updater/js": "0.29.4",
44
- "@hot-updater/test-utils": "0.29.4"
43
+ "@hot-updater/js": "0.29.6",
44
+ "@hot-updater/test-utils": "0.29.6"
45
45
  },
46
46
  "inlinedDependencies": {
47
47
  "camelcase": "8.0.0",