@flurryx/core 0.0.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.
package/dist/index.cjs ADDED
@@ -0,0 +1,62 @@
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 index_exports = {};
22
+ __export(index_exports, {
23
+ CACHE_NO_TIMEOUT: () => CACHE_NO_TIMEOUT,
24
+ DEFAULT_CACHE_TTL_MS: () => DEFAULT_CACHE_TTL_MS,
25
+ createKeyedResourceData: () => createKeyedResourceData,
26
+ isAnyKeyLoading: () => isAnyKeyLoading,
27
+ isKeyedResourceData: () => isKeyedResourceData
28
+ });
29
+ module.exports = __toCommonJS(index_exports);
30
+
31
+ // src/keyed-resource.ts
32
+ function isKeyedResourceData(value) {
33
+ if (typeof value !== "object" || value === null) {
34
+ return false;
35
+ }
36
+ const data = value;
37
+ return typeof data.entities === "object" && data.entities !== null && typeof data.isLoading === "object" && data.isLoading !== null && typeof data.status === "object" && data.status !== null && typeof data.errors === "object" && data.errors !== null;
38
+ }
39
+ function createKeyedResourceData() {
40
+ return {
41
+ entities: {},
42
+ isLoading: {},
43
+ status: {},
44
+ errors: {}
45
+ };
46
+ }
47
+ function isAnyKeyLoading(loading) {
48
+ return Object.values(loading).some((value) => value === true);
49
+ }
50
+
51
+ // src/constants.ts
52
+ var CACHE_NO_TIMEOUT = Infinity;
53
+ var DEFAULT_CACHE_TTL_MS = 5 * 60 * 1e3;
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ CACHE_NO_TIMEOUT,
57
+ DEFAULT_CACHE_TTL_MS,
58
+ createKeyedResourceData,
59
+ isAnyKeyLoading,
60
+ isKeyedResourceData
61
+ });
62
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/keyed-resource.ts","../src/constants.ts"],"sourcesContent":["export type { ResourceState, StoreEnum } from './resource-state';\nexport type {\n KeyedResourceData,\n KeyedResourceKey,\n ResourceStatus,\n ResourceErrors,\n} from './keyed-resource';\nexport {\n isKeyedResourceData,\n createKeyedResourceData,\n isAnyKeyLoading,\n} from './keyed-resource';\nexport { CACHE_NO_TIMEOUT, DEFAULT_CACHE_TTL_MS } from './constants';\n","import { ResourceState } from './resource-state';\n\nexport type KeyedResourceKey = string | number;\n\nexport type ResourceStatus = NonNullable<ResourceState<unknown>['status']>;\nexport type ResourceErrors = NonNullable<ResourceState<unknown>['errors']>;\n\nexport interface KeyedResourceData<TKey extends KeyedResourceKey, TValue> {\n entities: Partial<Record<TKey, TValue>>;\n isLoading: Partial<Record<TKey, boolean>>;\n status: Partial<Record<TKey, ResourceStatus>>;\n errors: Partial<Record<TKey, ResourceErrors>>;\n}\n\nexport function isKeyedResourceData(\n value: unknown\n): value is KeyedResourceData<KeyedResourceKey, unknown> {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n const data = value as Partial<KeyedResourceData<KeyedResourceKey, unknown>>;\n return (\n typeof data.entities === 'object' &&\n data.entities !== null &&\n typeof data.isLoading === 'object' &&\n data.isLoading !== null &&\n typeof data.status === 'object' &&\n data.status !== null &&\n typeof data.errors === 'object' &&\n data.errors !== null\n );\n}\n\nexport function createKeyedResourceData<\n TKey extends KeyedResourceKey,\n TValue,\n>(): KeyedResourceData<TKey, TValue> {\n return {\n entities: {} as Partial<Record<TKey, TValue>>,\n isLoading: {} as Partial<Record<TKey, boolean>>,\n status: {} as Partial<Record<TKey, ResourceStatus>>,\n errors: {} as Partial<Record<TKey, ResourceErrors>>,\n };\n}\n\nexport function isAnyKeyLoading<TKey extends KeyedResourceKey>(\n loading: Partial<Record<TKey, boolean>>\n): boolean {\n return Object.values(loading).some((value) => value === true);\n}\n","export const CACHE_NO_TIMEOUT = Infinity;\nexport const DEFAULT_CACHE_TTL_MS = 5 * 60 * 1000;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,SAAS,oBACd,OACuD;AACvD,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,WAAO;AAAA,EACT;AAEA,QAAM,OAAO;AACb,SACE,OAAO,KAAK,aAAa,YACzB,KAAK,aAAa,QAClB,OAAO,KAAK,cAAc,YAC1B,KAAK,cAAc,QACnB,OAAO,KAAK,WAAW,YACvB,KAAK,WAAW,QAChB,OAAO,KAAK,WAAW,YACvB,KAAK,WAAW;AAEpB;AAEO,SAAS,0BAGqB;AACnC,SAAO;AAAA,IACL,UAAU,CAAC;AAAA,IACX,WAAW,CAAC;AAAA,IACZ,QAAQ,CAAC;AAAA,IACT,QAAQ,CAAC;AAAA,EACX;AACF;AAEO,SAAS,gBACd,SACS;AACT,SAAO,OAAO,OAAO,OAAO,EAAE,KAAK,CAAC,UAAU,UAAU,IAAI;AAC9D;;;AClDO,IAAM,mBAAmB;AACzB,IAAM,uBAAuB,IAAI,KAAK;","names":[]}
@@ -0,0 +1,28 @@
1
+ interface ResourceState<T> {
2
+ isLoading?: boolean;
3
+ data?: T;
4
+ status?: 'Success' | 'Error';
5
+ errors?: Array<{
6
+ code: string;
7
+ message: string;
8
+ }>;
9
+ }
10
+ type StoreEnum = string | number | symbol;
11
+
12
+ type KeyedResourceKey = string | number;
13
+ type ResourceStatus = NonNullable<ResourceState<unknown>['status']>;
14
+ type ResourceErrors = NonNullable<ResourceState<unknown>['errors']>;
15
+ interface KeyedResourceData<TKey extends KeyedResourceKey, TValue> {
16
+ entities: Partial<Record<TKey, TValue>>;
17
+ isLoading: Partial<Record<TKey, boolean>>;
18
+ status: Partial<Record<TKey, ResourceStatus>>;
19
+ errors: Partial<Record<TKey, ResourceErrors>>;
20
+ }
21
+ declare function isKeyedResourceData(value: unknown): value is KeyedResourceData<KeyedResourceKey, unknown>;
22
+ declare function createKeyedResourceData<TKey extends KeyedResourceKey, TValue>(): KeyedResourceData<TKey, TValue>;
23
+ declare function isAnyKeyLoading<TKey extends KeyedResourceKey>(loading: Partial<Record<TKey, boolean>>): boolean;
24
+
25
+ declare const CACHE_NO_TIMEOUT: number;
26
+ declare const DEFAULT_CACHE_TTL_MS: number;
27
+
28
+ export { CACHE_NO_TIMEOUT, DEFAULT_CACHE_TTL_MS, type KeyedResourceData, type KeyedResourceKey, type ResourceErrors, type ResourceState, type ResourceStatus, type StoreEnum, createKeyedResourceData, isAnyKeyLoading, isKeyedResourceData };
@@ -0,0 +1,28 @@
1
+ interface ResourceState<T> {
2
+ isLoading?: boolean;
3
+ data?: T;
4
+ status?: 'Success' | 'Error';
5
+ errors?: Array<{
6
+ code: string;
7
+ message: string;
8
+ }>;
9
+ }
10
+ type StoreEnum = string | number | symbol;
11
+
12
+ type KeyedResourceKey = string | number;
13
+ type ResourceStatus = NonNullable<ResourceState<unknown>['status']>;
14
+ type ResourceErrors = NonNullable<ResourceState<unknown>['errors']>;
15
+ interface KeyedResourceData<TKey extends KeyedResourceKey, TValue> {
16
+ entities: Partial<Record<TKey, TValue>>;
17
+ isLoading: Partial<Record<TKey, boolean>>;
18
+ status: Partial<Record<TKey, ResourceStatus>>;
19
+ errors: Partial<Record<TKey, ResourceErrors>>;
20
+ }
21
+ declare function isKeyedResourceData(value: unknown): value is KeyedResourceData<KeyedResourceKey, unknown>;
22
+ declare function createKeyedResourceData<TKey extends KeyedResourceKey, TValue>(): KeyedResourceData<TKey, TValue>;
23
+ declare function isAnyKeyLoading<TKey extends KeyedResourceKey>(loading: Partial<Record<TKey, boolean>>): boolean;
24
+
25
+ declare const CACHE_NO_TIMEOUT: number;
26
+ declare const DEFAULT_CACHE_TTL_MS: number;
27
+
28
+ export { CACHE_NO_TIMEOUT, DEFAULT_CACHE_TTL_MS, type KeyedResourceData, type KeyedResourceKey, type ResourceErrors, type ResourceState, type ResourceStatus, type StoreEnum, createKeyedResourceData, isAnyKeyLoading, isKeyedResourceData };
package/dist/index.js ADDED
@@ -0,0 +1,31 @@
1
+ // src/keyed-resource.ts
2
+ function isKeyedResourceData(value) {
3
+ if (typeof value !== "object" || value === null) {
4
+ return false;
5
+ }
6
+ const data = value;
7
+ return typeof data.entities === "object" && data.entities !== null && typeof data.isLoading === "object" && data.isLoading !== null && typeof data.status === "object" && data.status !== null && typeof data.errors === "object" && data.errors !== null;
8
+ }
9
+ function createKeyedResourceData() {
10
+ return {
11
+ entities: {},
12
+ isLoading: {},
13
+ status: {},
14
+ errors: {}
15
+ };
16
+ }
17
+ function isAnyKeyLoading(loading) {
18
+ return Object.values(loading).some((value) => value === true);
19
+ }
20
+
21
+ // src/constants.ts
22
+ var CACHE_NO_TIMEOUT = Infinity;
23
+ var DEFAULT_CACHE_TTL_MS = 5 * 60 * 1e3;
24
+ export {
25
+ CACHE_NO_TIMEOUT,
26
+ DEFAULT_CACHE_TTL_MS,
27
+ createKeyedResourceData,
28
+ isAnyKeyLoading,
29
+ isKeyedResourceData
30
+ };
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/keyed-resource.ts","../src/constants.ts"],"sourcesContent":["import { ResourceState } from './resource-state';\n\nexport type KeyedResourceKey = string | number;\n\nexport type ResourceStatus = NonNullable<ResourceState<unknown>['status']>;\nexport type ResourceErrors = NonNullable<ResourceState<unknown>['errors']>;\n\nexport interface KeyedResourceData<TKey extends KeyedResourceKey, TValue> {\n entities: Partial<Record<TKey, TValue>>;\n isLoading: Partial<Record<TKey, boolean>>;\n status: Partial<Record<TKey, ResourceStatus>>;\n errors: Partial<Record<TKey, ResourceErrors>>;\n}\n\nexport function isKeyedResourceData(\n value: unknown\n): value is KeyedResourceData<KeyedResourceKey, unknown> {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n const data = value as Partial<KeyedResourceData<KeyedResourceKey, unknown>>;\n return (\n typeof data.entities === 'object' &&\n data.entities !== null &&\n typeof data.isLoading === 'object' &&\n data.isLoading !== null &&\n typeof data.status === 'object' &&\n data.status !== null &&\n typeof data.errors === 'object' &&\n data.errors !== null\n );\n}\n\nexport function createKeyedResourceData<\n TKey extends KeyedResourceKey,\n TValue,\n>(): KeyedResourceData<TKey, TValue> {\n return {\n entities: {} as Partial<Record<TKey, TValue>>,\n isLoading: {} as Partial<Record<TKey, boolean>>,\n status: {} as Partial<Record<TKey, ResourceStatus>>,\n errors: {} as Partial<Record<TKey, ResourceErrors>>,\n };\n}\n\nexport function isAnyKeyLoading<TKey extends KeyedResourceKey>(\n loading: Partial<Record<TKey, boolean>>\n): boolean {\n return Object.values(loading).some((value) => value === true);\n}\n","export const CACHE_NO_TIMEOUT = Infinity;\nexport const DEFAULT_CACHE_TTL_MS = 5 * 60 * 1000;\n"],"mappings":";AAcO,SAAS,oBACd,OACuD;AACvD,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,WAAO;AAAA,EACT;AAEA,QAAM,OAAO;AACb,SACE,OAAO,KAAK,aAAa,YACzB,KAAK,aAAa,QAClB,OAAO,KAAK,cAAc,YAC1B,KAAK,cAAc,QACnB,OAAO,KAAK,WAAW,YACvB,KAAK,WAAW,QAChB,OAAO,KAAK,WAAW,YACvB,KAAK,WAAW;AAEpB;AAEO,SAAS,0BAGqB;AACnC,SAAO;AAAA,IACL,UAAU,CAAC;AAAA,IACX,WAAW,CAAC;AAAA,IACZ,QAAQ,CAAC;AAAA,IACT,QAAQ,CAAC;AAAA,EACX;AACF;AAEO,SAAS,gBACd,SACS;AACT,SAAO,OAAO,OAAO,OAAO,EAAE,KAAK,CAAC,UAAU,UAAU,IAAI;AAC9D;;;AClDO,IAAM,mBAAmB;AACzB,IAAM,uBAAuB,IAAI,KAAK;","names":[]}
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@flurryx/core",
3
+ "version": "0.0.1",
4
+ "description": "Core types and utilities for flurryx state management",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
+ },
16
+ "require": {
17
+ "types": "./dist/index.d.cts",
18
+ "default": "./dist/index.cjs"
19
+ }
20
+ }
21
+ },
22
+ "files": ["dist"],
23
+ "scripts": {
24
+ "build": "tsup",
25
+ "typecheck": "tsc --noEmit"
26
+ },
27
+ "sideEffects": false
28
+ }