@hot-updater/postgres 0.1.6-0 → 0.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.
package/dist/index.cjs CHANGED
@@ -1,126 +1,124 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- postgres: () => postgres
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = function(exports1, definition) {
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = function(obj, prop) {
13
+ return Object.prototype.hasOwnProperty.call(obj, prop);
14
+ };
15
+ })();
16
+ (()=>{
17
+ __webpack_require__.r = function(exports1) {
18
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
19
+ value: 'Module'
20
+ });
21
+ Object.defineProperty(exports1, '__esModule', {
22
+ value: true
23
+ });
24
+ };
25
+ })();
26
+ var __webpack_exports__ = {};
27
+ __webpack_require__.r(__webpack_exports__);
28
+ __webpack_require__.d(__webpack_exports__, {
29
+ postgres: ()=>postgres
24
30
  });
25
- module.exports = __toCommonJS(src_exports);
26
-
27
- // src/postgres.ts
28
- var import_kysely = require("kysely");
29
- var import_pg = require("pg");
30
- var postgres = (config, hooks) => (_) => {
31
- const pool = new import_pg.Pool(config);
32
- const dialect = new import_kysely.PostgresDialect({
33
- pool
34
- });
35
- const db = new import_kysely.Kysely({
36
- dialect
37
- });
38
- let bundles = [];
39
- return {
40
- async onUnmount() {
41
- await pool.end();
42
- },
43
- async commitBundle() {
44
- await db.transaction().execute(async (tx) => {
45
- for (const bundle of bundles) {
46
- tx.insertInto("bundles").values({
47
- id: bundle.id,
48
- enabled: bundle.enabled,
49
- file_url: bundle.fileUrl,
50
- force_update: bundle.forceUpdate,
51
- file_hash: bundle.fileHash,
52
- git_commit_hash: bundle.gitCommitHash,
53
- message: bundle.message,
54
- platform: bundle.platform,
55
- target_version: bundle.targetVersion
56
- }).onConflict(
57
- (oc) => oc.column("id").doUpdateSet({
58
- enabled: bundle.enabled,
59
- file_url: bundle.fileUrl,
60
- force_update: bundle.forceUpdate,
61
- file_hash: bundle.fileHash,
62
- git_commit_hash: bundle.gitCommitHash,
63
- message: bundle.message,
64
- platform: bundle.platform,
65
- target_version: bundle.targetVersion
66
- })
67
- ).execute();
68
- }
69
- });
70
- hooks?.onDatabaseUpdated?.();
71
- },
72
- async updateBundle(targetBundleId, newBundle) {
73
- bundles = await this.getBundles();
74
- const targetIndex = bundles.findIndex((u) => u.id === targetBundleId);
75
- if (targetIndex === -1) {
76
- throw new Error("target bundle version not found");
77
- }
78
- Object.assign(bundles[targetIndex], newBundle);
79
- },
80
- async appendBundle(inputBundle) {
81
- bundles = await this.getBundles();
82
- bundles.unshift(inputBundle);
83
- },
84
- async setBundles(inputBundles) {
85
- bundles = inputBundles;
86
- },
87
- async getBundleById(bundleId) {
88
- const data = await db.selectFrom("bundles").selectAll().where("id", "=", bundleId).executeTakeFirst();
89
- if (!data) {
90
- return null;
91
- }
92
- return {
93
- enabled: data.enabled,
94
- fileUrl: data.file_url,
95
- forceUpdate: data.force_update,
96
- fileHash: data.file_hash,
97
- gitCommitHash: data.git_commit_hash,
98
- id: data.id,
99
- message: data.message,
100
- platform: data.platform,
101
- targetVersion: data.target_version
102
- };
103
- },
104
- async getBundles(refresh = false) {
105
- if (bundles.length > 0 && !refresh) {
106
- return bundles;
107
- }
108
- const data = await db.selectFrom("bundles").selectAll().execute();
109
- return data.map((bundle) => ({
110
- enabled: bundle.enabled,
111
- fileUrl: bundle.file_url,
112
- forceUpdate: bundle.force_update,
113
- fileHash: bundle.file_hash,
114
- gitCommitHash: bundle.git_commit_hash,
115
- id: bundle.id,
116
- message: bundle.message,
117
- platform: bundle.platform,
118
- targetVersion: bundle.target_version
119
- }));
120
- }
121
- };
122
- };
123
- // Annotate the CommonJS export names for ESM import in node:
124
- 0 && (module.exports = {
125
- postgres
31
+ const external_kysely_namespaceObject = require("kysely");
32
+ const external_pg_namespaceObject = require("pg");
33
+ const postgres = (config, hooks)=>(_)=>{
34
+ const pool = new external_pg_namespaceObject.Pool(config);
35
+ const dialect = new external_kysely_namespaceObject.PostgresDialect({
36
+ pool
37
+ });
38
+ const db = new external_kysely_namespaceObject.Kysely({
39
+ dialect
40
+ });
41
+ let bundles = [];
42
+ let isUnmount = false;
43
+ return {
44
+ name: "postgres",
45
+ async onUnmount () {
46
+ if (isUnmount) return;
47
+ isUnmount = true;
48
+ await pool.end();
49
+ },
50
+ async commitBundle () {
51
+ await db.transaction().execute(async (tx)=>{
52
+ for (const bundle of bundles)await tx.insertInto("bundles").values({
53
+ id: bundle.id,
54
+ enabled: bundle.enabled,
55
+ file_url: bundle.fileUrl,
56
+ force_update: bundle.forceUpdate,
57
+ file_hash: bundle.fileHash,
58
+ git_commit_hash: bundle.gitCommitHash,
59
+ message: bundle.message,
60
+ platform: bundle.platform,
61
+ target_app_version: bundle.targetAppVersion
62
+ }).onConflict((oc)=>oc.column("id").doUpdateSet({
63
+ enabled: bundle.enabled,
64
+ file_url: bundle.fileUrl,
65
+ force_update: bundle.forceUpdate,
66
+ file_hash: bundle.fileHash,
67
+ git_commit_hash: bundle.gitCommitHash,
68
+ message: bundle.message,
69
+ platform: bundle.platform,
70
+ target_app_version: bundle.targetAppVersion
71
+ })).execute();
72
+ });
73
+ hooks?.onDatabaseUpdated?.();
74
+ },
75
+ async updateBundle (targetBundleId, newBundle) {
76
+ bundles = await this.getBundles();
77
+ const targetIndex = bundles.findIndex((u)=>u.id === targetBundleId);
78
+ if (-1 === targetIndex) throw new Error("target bundle version not found");
79
+ Object.assign(bundles[targetIndex], newBundle);
80
+ },
81
+ async appendBundle (inputBundle) {
82
+ bundles = await this.getBundles();
83
+ bundles.unshift(inputBundle);
84
+ },
85
+ async setBundles (inputBundles) {
86
+ bundles = inputBundles;
87
+ },
88
+ async getBundleById (bundleId) {
89
+ const data = await db.selectFrom("bundles").selectAll().where("id", "=", bundleId).executeTakeFirst();
90
+ if (!data) return null;
91
+ return {
92
+ enabled: data.enabled,
93
+ fileUrl: data.file_url,
94
+ forceUpdate: data.force_update,
95
+ fileHash: data.file_hash,
96
+ gitCommitHash: data.git_commit_hash,
97
+ id: data.id,
98
+ message: data.message,
99
+ platform: data.platform,
100
+ targetAppVersion: data.target_app_version
101
+ };
102
+ },
103
+ async getBundles (refresh = false) {
104
+ if (bundles.length > 0 && !refresh) return bundles;
105
+ const data = await db.selectFrom("bundles").orderBy("id", "desc").selectAll().execute();
106
+ return data.map((bundle)=>({
107
+ enabled: bundle.enabled,
108
+ fileUrl: bundle.file_url,
109
+ forceUpdate: bundle.force_update,
110
+ fileHash: bundle.file_hash,
111
+ gitCommitHash: bundle.git_commit_hash,
112
+ id: bundle.id,
113
+ message: bundle.message,
114
+ platform: bundle.platform,
115
+ targetAppVersion: bundle.target_app_version
116
+ }));
117
+ }
118
+ };
119
+ };
120
+ var __webpack_export_target__ = exports;
121
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
122
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
123
+ value: true
126
124
  });
package/dist/index.d.ts CHANGED
@@ -1,8 +1 @@
1
- import { DatabasePluginHooks, BasePluginArgs, DatabasePlugin } from '@hot-updater/plugin-core';
2
- import { PoolConfig } from 'pg';
3
-
4
- interface PostgresConfig extends PoolConfig {
5
- }
6
- declare const postgres: (config: PostgresConfig, hooks?: DatabasePluginHooks) => (_: BasePluginArgs) => DatabasePlugin;
7
-
8
- export { type PostgresConfig, postgres };
1
+ export * from "./postgres";
package/dist/index.js CHANGED
@@ -1,99 +1,90 @@
1
- // src/postgres.ts
2
- import { Kysely, PostgresDialect } from "kysely";
3
- import { Pool } from "pg";
4
- var postgres = (config, hooks) => (_) => {
5
- const pool = new Pool(config);
6
- const dialect = new PostgresDialect({
7
- pool
8
- });
9
- const db = new Kysely({
10
- dialect
11
- });
12
- let bundles = [];
13
- return {
14
- async onUnmount() {
15
- await pool.end();
16
- },
17
- async commitBundle() {
18
- await db.transaction().execute(async (tx) => {
19
- for (const bundle of bundles) {
20
- tx.insertInto("bundles").values({
21
- id: bundle.id,
22
- enabled: bundle.enabled,
23
- file_url: bundle.fileUrl,
24
- force_update: bundle.forceUpdate,
25
- file_hash: bundle.fileHash,
26
- git_commit_hash: bundle.gitCommitHash,
27
- message: bundle.message,
28
- platform: bundle.platform,
29
- target_version: bundle.targetVersion
30
- }).onConflict(
31
- (oc) => oc.column("id").doUpdateSet({
32
- enabled: bundle.enabled,
33
- file_url: bundle.fileUrl,
34
- force_update: bundle.forceUpdate,
35
- file_hash: bundle.fileHash,
36
- git_commit_hash: bundle.gitCommitHash,
37
- message: bundle.message,
38
- platform: bundle.platform,
39
- target_version: bundle.targetVersion
40
- })
41
- ).execute();
42
- }
43
- });
44
- hooks?.onDatabaseUpdated?.();
45
- },
46
- async updateBundle(targetBundleId, newBundle) {
47
- bundles = await this.getBundles();
48
- const targetIndex = bundles.findIndex((u) => u.id === targetBundleId);
49
- if (targetIndex === -1) {
50
- throw new Error("target bundle version not found");
51
- }
52
- Object.assign(bundles[targetIndex], newBundle);
53
- },
54
- async appendBundle(inputBundle) {
55
- bundles = await this.getBundles();
56
- bundles.unshift(inputBundle);
57
- },
58
- async setBundles(inputBundles) {
59
- bundles = inputBundles;
60
- },
61
- async getBundleById(bundleId) {
62
- const data = await db.selectFrom("bundles").selectAll().where("id", "=", bundleId).executeTakeFirst();
63
- if (!data) {
64
- return null;
65
- }
66
- return {
67
- enabled: data.enabled,
68
- fileUrl: data.file_url,
69
- forceUpdate: data.force_update,
70
- fileHash: data.file_hash,
71
- gitCommitHash: data.git_commit_hash,
72
- id: data.id,
73
- message: data.message,
74
- platform: data.platform,
75
- targetVersion: data.target_version
76
- };
77
- },
78
- async getBundles(refresh = false) {
79
- if (bundles.length > 0 && !refresh) {
80
- return bundles;
81
- }
82
- const data = await db.selectFrom("bundles").selectAll().execute();
83
- return data.map((bundle) => ({
84
- enabled: bundle.enabled,
85
- fileUrl: bundle.file_url,
86
- forceUpdate: bundle.force_update,
87
- fileHash: bundle.file_hash,
88
- gitCommitHash: bundle.git_commit_hash,
89
- id: bundle.id,
90
- message: bundle.message,
91
- platform: bundle.platform,
92
- targetVersion: bundle.target_version
93
- }));
94
- }
95
- };
96
- };
97
- export {
98
- postgres
99
- };
1
+ import * as __WEBPACK_EXTERNAL_MODULE_kysely__ from "kysely";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_pg__ from "pg";
3
+ const postgres = (config, hooks)=>(_)=>{
4
+ const pool = new __WEBPACK_EXTERNAL_MODULE_pg__.Pool(config);
5
+ const dialect = new __WEBPACK_EXTERNAL_MODULE_kysely__.PostgresDialect({
6
+ pool
7
+ });
8
+ const db = new __WEBPACK_EXTERNAL_MODULE_kysely__.Kysely({
9
+ dialect
10
+ });
11
+ let bundles = [];
12
+ let isUnmount = false;
13
+ return {
14
+ name: "postgres",
15
+ async onUnmount () {
16
+ if (isUnmount) return;
17
+ isUnmount = true;
18
+ await pool.end();
19
+ },
20
+ async commitBundle () {
21
+ await db.transaction().execute(async (tx)=>{
22
+ for (const bundle of bundles)await tx.insertInto("bundles").values({
23
+ id: bundle.id,
24
+ enabled: bundle.enabled,
25
+ file_url: bundle.fileUrl,
26
+ force_update: bundle.forceUpdate,
27
+ file_hash: bundle.fileHash,
28
+ git_commit_hash: bundle.gitCommitHash,
29
+ message: bundle.message,
30
+ platform: bundle.platform,
31
+ target_app_version: bundle.targetAppVersion
32
+ }).onConflict((oc)=>oc.column("id").doUpdateSet({
33
+ enabled: bundle.enabled,
34
+ file_url: bundle.fileUrl,
35
+ force_update: bundle.forceUpdate,
36
+ file_hash: bundle.fileHash,
37
+ git_commit_hash: bundle.gitCommitHash,
38
+ message: bundle.message,
39
+ platform: bundle.platform,
40
+ target_app_version: bundle.targetAppVersion
41
+ })).execute();
42
+ });
43
+ hooks?.onDatabaseUpdated?.();
44
+ },
45
+ async updateBundle (targetBundleId, newBundle) {
46
+ bundles = await this.getBundles();
47
+ const targetIndex = bundles.findIndex((u)=>u.id === targetBundleId);
48
+ if (-1 === targetIndex) throw new Error("target bundle version not found");
49
+ Object.assign(bundles[targetIndex], newBundle);
50
+ },
51
+ async appendBundle (inputBundle) {
52
+ bundles = await this.getBundles();
53
+ bundles.unshift(inputBundle);
54
+ },
55
+ async setBundles (inputBundles) {
56
+ bundles = inputBundles;
57
+ },
58
+ async getBundleById (bundleId) {
59
+ const data = await db.selectFrom("bundles").selectAll().where("id", "=", bundleId).executeTakeFirst();
60
+ if (!data) return null;
61
+ return {
62
+ enabled: data.enabled,
63
+ fileUrl: data.file_url,
64
+ forceUpdate: data.force_update,
65
+ fileHash: data.file_hash,
66
+ gitCommitHash: data.git_commit_hash,
67
+ id: data.id,
68
+ message: data.message,
69
+ platform: data.platform,
70
+ targetAppVersion: data.target_app_version
71
+ };
72
+ },
73
+ async getBundles (refresh = false) {
74
+ if (bundles.length > 0 && !refresh) return bundles;
75
+ const data = await db.selectFrom("bundles").orderBy("id", "desc").selectAll().execute();
76
+ return data.map((bundle)=>({
77
+ enabled: bundle.enabled,
78
+ fileUrl: bundle.file_url,
79
+ forceUpdate: bundle.force_update,
80
+ fileHash: bundle.file_hash,
81
+ gitCommitHash: bundle.git_commit_hash,
82
+ id: bundle.id,
83
+ message: bundle.message,
84
+ platform: bundle.platform,
85
+ targetAppVersion: bundle.target_app_version
86
+ }));
87
+ }
88
+ };
89
+ };
90
+ export { postgres };
@@ -0,0 +1,5 @@
1
+ import type { BasePluginArgs, DatabasePlugin, DatabasePluginHooks } from "@hot-updater/plugin-core";
2
+ import { type PoolConfig } from "pg";
3
+ export interface PostgresConfig extends PoolConfig {
4
+ }
5
+ export declare const postgres: (config: PostgresConfig, hooks?: DatabasePluginHooks) => (_: BasePluginArgs) => DatabasePlugin;
@@ -0,0 +1,10 @@
1
+ import type { Bundle } from "@hot-updater/core";
2
+ type SnakeCase<S extends string> = S extends `${infer T}${infer U}` ? `${T extends Capitalize<T> ? "_" : ""}${Lowercase<T>}${SnakeCase<U>}` : S;
3
+ type SnakeKeyObject<T> = T extends Record<string, any> ? {
4
+ [K in keyof T as SnakeCase<Extract<K, string>>]: T[K] extends object ? SnakeKeyObject<T[K]> : T[K];
5
+ } : T;
6
+ export type BundlesTable = SnakeKeyObject<Bundle>;
7
+ export interface Database {
8
+ bundles: BundlesTable;
9
+ }
10
+ export {};
package/package.json CHANGED
@@ -1,10 +1,17 @@
1
1
  {
2
2
  "name": "@hot-updater/postgres",
3
3
  "type": "module",
4
- "version": "0.1.6-0",
4
+ "version": "0.3.0",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.cjs"
12
+ },
13
+ "./sql": "./sql"
14
+ },
8
15
  "types": "dist/index.d.ts",
9
16
  "license": "MIT",
10
17
  "repository": "https://github.com/gronxb/hot-updater",
@@ -22,9 +29,9 @@
22
29
  "package.json"
23
30
  ],
24
31
  "dependencies": {
25
- "@hot-updater/core": "0.1.6-0",
26
- "@hot-updater/plugin-core": "0.1.6-0",
27
- "kysely": "^0.27.4",
32
+ "@hot-updater/core": "0.3.0",
33
+ "@hot-updater/plugin-core": "0.3.0",
34
+ "kysely": "^0.27.5",
28
35
  "pg": "^8.13.1"
29
36
  },
30
37
  "devDependencies": {
@@ -33,7 +40,7 @@
33
40
  "camelcase-keys": "^9.1.3"
34
41
  },
35
42
  "scripts": {
36
- "build": "tsup src/index.ts --format cjs,esm --dts",
43
+ "build": "rslib build",
37
44
  "test:type": "tsc --noEmit"
38
45
  }
39
46
  }
package/sql/bundles.sql CHANGED
@@ -1,9 +1,11 @@
1
+ -- HotUpdater.bundles
2
+
1
3
  CREATE TYPE platforms AS ENUM ('ios', 'android');
2
4
 
3
5
  CREATE TABLE bundles (
4
6
  id uuid PRIMARY KEY,
5
7
  platform platforms NOT NULL,
6
- target_version text NOT NULL,
8
+ target_app_version text NOT NULL,
7
9
  force_update boolean NOT NULL,
8
10
  enabled boolean NOT NULL,
9
11
  file_url text NOT NULL,
@@ -11,3 +13,5 @@ CREATE TABLE bundles (
11
13
  git_commit_hash text,
12
14
  message text
13
15
  );
16
+
17
+ CREATE INDEX bundles_target_app_version_idx ON bundles(target_app_version);
@@ -1,7 +1,9 @@
1
+ -- HotUpdater.get_update_info
2
+
1
3
  CREATE OR REPLACE FUNCTION get_update_info (
2
- current_platform platforms,
3
- current_app_version text,
4
- current_bundle_id uuid
4
+ app_platform platforms,
5
+ app_version text,
6
+ bundle_id uuid
5
7
  )
6
8
  RETURNS TABLE (
7
9
  id uuid,
@@ -27,8 +29,8 @@ BEGIN
27
29
  'ROLLBACK' AS status
28
30
  FROM bundles b
29
31
  WHERE b.enabled = TRUE
30
- AND b.platform = current_platform
31
- AND b.id < current_bundle_id
32
+ AND b.platform = app_platform
33
+ AND b.id < bundle_id
32
34
  ORDER BY b.id DESC
33
35
  LIMIT 1
34
36
  ),
@@ -41,9 +43,9 @@ BEGIN
41
43
  'UPDATE' AS status
42
44
  FROM bundles b
43
45
  WHERE b.enabled = TRUE
44
- AND b.platform = current_platform
45
- AND b.id >= current_bundle_id
46
- AND semver_satisfies(b.target_version, current_app_version)
46
+ AND b.platform = app_platform
47
+ AND b.id >= bundle_id
48
+ AND semver_satisfies(b.target_app_version, app_version)
47
49
  ORDER BY b.id DESC
48
50
  LIMIT 1
49
51
  ),
@@ -58,11 +60,11 @@ BEGIN
58
60
  WHERE NOT EXISTS (SELECT 1 FROM update_candidate)
59
61
  )
60
62
  SELECT *
61
- FROM final_result WHERE final_result.id != current_bundle_id
63
+ FROM final_result WHERE final_result.id != bundle_id
62
64
 
63
65
  UNION ALL
64
66
  /*
65
- When there are no final results and current_bundle_id != NIL_UUID,
67
+ When there are no final results and bundle_id != NIL_UUID,
66
68
  add one fallback row.
67
69
  This fallback row is also ROLLBACK so forceUpdate = TRUE.
68
70
  */
@@ -73,7 +75,7 @@ BEGIN
73
75
  NULL AS file_hash,
74
76
  'ROLLBACK' AS status
75
77
  WHERE (SELECT COUNT(*) FROM final_result) = 0
76
- AND current_bundle_id != NIL_UUID;
78
+ AND bundle_id != NIL_UUID;
77
79
 
78
80
  END;
79
81
  $$;
@@ -8,14 +8,14 @@ import { prepareSql } from "./prepareSql";
8
8
  const createInsertBundleQuery = (bundle: Bundle) => {
9
9
  return `
10
10
  INSERT INTO bundles (
11
- id, file_url, file_hash, platform, target_version,
11
+ id, file_url, file_hash, platform, target_app_version,
12
12
  force_update, enabled, git_commit_hash, message
13
13
  ) VALUES (
14
14
  '${bundle.id}',
15
15
  '${bundle.fileUrl}',
16
16
  '${bundle.fileHash}',
17
17
  '${bundle.platform}',
18
- '${bundle.targetVersion}',
18
+ '${bundle.targetAppVersion}',
19
19
  ${bundle.forceUpdate},
20
20
  ${bundle.enabled},
21
21
  ${bundle.gitCommitHash ? `'${bundle.gitCommitHash}'` : "null"},
@@ -1,3 +1,5 @@
1
+ -- HotUpdater.semver_satisfies
2
+
1
3
  CREATE OR REPLACE FUNCTION semver_satisfies(range_expression TEXT, version TEXT)
2
4
  RETURNS BOOLEAN AS $$
3
5
  DECLARE
@@ -8,9 +8,9 @@ const sql = await prepareSql();
8
8
  await db.exec(sql);
9
9
 
10
10
  const createSemverSatisfies =
11
- (db: PGlite) => async (targetVersion: string, currentVersion: string) => {
11
+ (db: PGlite) => async (targetAppVersion: string, currentVersion: string) => {
12
12
  const result = await db.query<{ actual: boolean }>(`
13
- SELECT semver_satisfies('${targetVersion}', '${currentVersion}') AS actual;
13
+ SELECT semver_satisfies('${targetAppVersion}', '${currentVersion}') AS actual;
14
14
  `);
15
15
  return result.rows[0].actual;
16
16
  };
package/dist/index.d.cts DELETED
@@ -1,8 +0,0 @@
1
- import { DatabasePluginHooks, BasePluginArgs, DatabasePlugin } from '@hot-updater/plugin-core';
2
- import { PoolConfig } from 'pg';
3
-
4
- interface PostgresConfig extends PoolConfig {
5
- }
6
- declare const postgres: (config: PostgresConfig, hooks?: DatabasePluginHooks) => (_: BasePluginArgs) => DatabasePlugin;
7
-
8
- export { type PostgresConfig, postgres };