@junobuild/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/LICENSE +21 -0
- package/README.md +17 -0
- package/dist/cjs/index.cjs.js +71 -0
- package/dist/cjs/index.cjs.js.map +7 -0
- package/dist/esm/canisterStatus-KN67PLOF.js +2 -0
- package/dist/esm/canisterStatus-KN67PLOF.js.map +7 -0
- package/dist/esm/chunk-VT367M3F.js +63 -0
- package/dist/esm/chunk-VT367M3F.js.map +7 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/api/actor.api.d.ts +3 -0
- package/dist/types/api/doc.api.d.ts +22 -0
- package/dist/types/api/storage.api.d.ts +21 -0
- package/dist/types/constants/auth.constants.d.ts +2 -0
- package/dist/types/events/log.events.d.ts +6 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/services/auth.services.d.ts +6 -0
- package/dist/types/services/doc.services.d.ts +22 -0
- package/dist/types/services/identity.services.d.ts +2 -0
- package/dist/types/services/storage.services.d.ts +25 -0
- package/dist/types/services/user.services.d.ts +2 -0
- package/dist/types/stores/auth.store.d.ts +13 -0
- package/dist/types/stores/env.store.d.ts +12 -0
- package/dist/types/stores/store.d.ts +5 -0
- package/dist/types/types/auth.types.d.ts +13 -0
- package/dist/types/types/doc.types.d.ts +6 -0
- package/dist/types/types/env.types.d.ts +4 -0
- package/dist/types/types/list.types.d.ts +17 -0
- package/dist/types/types/satellite.types.d.ts +8 -0
- package/dist/types/types/storage.types.d.ts +30 -0
- package/dist/types/utils/actor.utils.d.ts +6 -0
- package/dist/types/utils/crypto.utils.d.ts +1 -0
- package/dist/types/utils/did.utils.d.ts +4 -0
- package/dist/types/utils/env.utils.d.ts +2 -0
- package/dist/types/utils/list.utils.d.ts +9 -0
- package/dist/types/utils/storage.utils.d.ts +1 -0
- package/dist/types/utils/utils.d.ts +7 -0
- package/package.json +38 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./cjs/index.cjs.js');
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './esm/index.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Doc } from '../types/doc.types';
|
|
2
|
+
import type { ListParams, ListResults } from '../types/list.types';
|
|
3
|
+
import type { Satellite } from '../types/satellite.types';
|
|
4
|
+
export declare const getDoc: <D>({ collection, key, satellite }: {
|
|
5
|
+
collection: string;
|
|
6
|
+
satellite: Satellite;
|
|
7
|
+
} & Pick<Doc<D>, "key">) => Promise<Doc<D> | undefined>;
|
|
8
|
+
export declare const setDoc: <D>({ collection, doc, satellite }: {
|
|
9
|
+
collection: string;
|
|
10
|
+
doc: Doc<D>;
|
|
11
|
+
satellite: Satellite;
|
|
12
|
+
}) => Promise<Doc<D>>;
|
|
13
|
+
export declare const delDoc: <D>({ collection, doc, satellite }: {
|
|
14
|
+
collection: string;
|
|
15
|
+
doc: Doc<D>;
|
|
16
|
+
satellite: Satellite;
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
export declare const listDocs: <D>({ collection, filter, satellite }: {
|
|
19
|
+
collection: string;
|
|
20
|
+
filter: ListParams;
|
|
21
|
+
satellite: Satellite;
|
|
22
|
+
}) => Promise<ListResults<Doc<D>>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AssetNoContent } from '../../../declarations/satellite/satellite.did';
|
|
2
|
+
import type { ListParams, ListResults } from '../types/list.types';
|
|
3
|
+
import type { Satellite } from '../types/satellite.types';
|
|
4
|
+
import type { Asset, Storage } from '../types/storage.types';
|
|
5
|
+
export declare const uploadAsset: ({ data, filename, collection, headers, token, fullPath, encoding, satellite }: Required<Omit<Storage, "token" | "encoding">> & Pick<Storage, "token" | "encoding"> & {
|
|
6
|
+
satellite: Satellite;
|
|
7
|
+
}) => Promise<void>;
|
|
8
|
+
export declare const listAssets: ({ collection, satellite, filter }: {
|
|
9
|
+
collection: string;
|
|
10
|
+
satellite: Satellite;
|
|
11
|
+
filter: ListParams;
|
|
12
|
+
}) => Promise<ListResults<AssetNoContent>>;
|
|
13
|
+
export declare const deleteAsset: ({ collection, storageFile, satellite }: {
|
|
14
|
+
collection: string;
|
|
15
|
+
storageFile: Asset;
|
|
16
|
+
satellite: Satellite;
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
export declare const deleteAssets: ({ collection, satellite }: {
|
|
19
|
+
collection?: string | undefined;
|
|
20
|
+
satellite: Satellite;
|
|
21
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Environment } from './types/env.types';
|
|
2
|
+
export { signIn, signOut } from './services/auth.services';
|
|
3
|
+
export * from './services/doc.services';
|
|
4
|
+
export * from './services/storage.services';
|
|
5
|
+
export * from './types/auth.types';
|
|
6
|
+
export * from './types/doc.types';
|
|
7
|
+
export { ListParams, ListResults, OrderDocs, PaginateDocs } from './types/list.types';
|
|
8
|
+
export * from './types/satellite.types';
|
|
9
|
+
export * from './types/storage.types';
|
|
10
|
+
import type { User } from './types/auth.types';
|
|
11
|
+
export declare const initDapp: (env: Environment) => Promise<void>;
|
|
12
|
+
export declare const authSubscribe: (callback: (authUser: User | null) => void) => (() => void);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Identity } from '@dfinity/agent';
|
|
2
|
+
import type { SignInOptions } from '../types/auth.types';
|
|
3
|
+
export declare const initAuth: () => Promise<void>;
|
|
4
|
+
export declare const signIn: (options?: SignInOptions) => Promise<void>;
|
|
5
|
+
export declare const signOut: () => Promise<void>;
|
|
6
|
+
export declare const getIdentity: () => Identity | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Doc } from '../types/doc.types';
|
|
2
|
+
import type { ListParams, ListResults } from '../types/list.types';
|
|
3
|
+
import type { SatelliteOptions } from '../types/satellite.types';
|
|
4
|
+
export declare const getDoc: <D>({ satellite, ...rest }: {
|
|
5
|
+
collection: string;
|
|
6
|
+
satellite?: Partial<import("../types/satellite.types").Satellite> | undefined;
|
|
7
|
+
} & Pick<Doc<D>, "key">) => Promise<Doc<D> | undefined>;
|
|
8
|
+
export declare const setDoc: <D>({ satellite, ...rest }: {
|
|
9
|
+
collection: string;
|
|
10
|
+
doc: Doc<D>;
|
|
11
|
+
satellite?: Partial<import("../types/satellite.types").Satellite> | undefined;
|
|
12
|
+
}) => Promise<Doc<D>>;
|
|
13
|
+
export declare const delDoc: <D>({ satellite, ...rest }: {
|
|
14
|
+
collection: string;
|
|
15
|
+
doc: Doc<D>;
|
|
16
|
+
satellite?: Partial<import("../types/satellite.types").Satellite> | undefined;
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
export declare const listDocs: <D>({ satellite, ...rest }: {
|
|
19
|
+
collection: string;
|
|
20
|
+
filter: ListParams;
|
|
21
|
+
satellite?: Partial<import("../types/satellite.types").Satellite> | undefined;
|
|
22
|
+
}) => Promise<ListResults<Doc<D>>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ListParams } from '../types/list.types';
|
|
2
|
+
import type { SatelliteOptions } from '../types/satellite.types';
|
|
3
|
+
import type { Asset, AssetKey, Assets, Storage } from '../types/storage.types';
|
|
4
|
+
export declare const uploadBlob: (params: Storage & {
|
|
5
|
+
satellite?: SatelliteOptions;
|
|
6
|
+
}) => Promise<AssetKey>;
|
|
7
|
+
export declare const uploadFile: (params: Partial<Pick<Storage, 'filename'>> & Omit<Storage, 'filename' | 'data'> & {
|
|
8
|
+
data: File;
|
|
9
|
+
} & {
|
|
10
|
+
satellite?: SatelliteOptions;
|
|
11
|
+
}) => Promise<AssetKey>;
|
|
12
|
+
export declare const listAssets: ({ collection, satellite, filter }: {
|
|
13
|
+
collection: string;
|
|
14
|
+
satellite?: Partial<import("../types/satellite.types").Satellite> | undefined;
|
|
15
|
+
filter?: ListParams | undefined;
|
|
16
|
+
}) => Promise<Assets>;
|
|
17
|
+
export declare const deleteAsset: ({ storageFile, collection, satellite }: {
|
|
18
|
+
storageFile: Asset;
|
|
19
|
+
collection: string;
|
|
20
|
+
satellite?: Partial<import("../types/satellite.types").Satellite> | undefined;
|
|
21
|
+
}) => Promise<void>;
|
|
22
|
+
export declare const deleteAssets: ({ collection, satellite }: {
|
|
23
|
+
collection?: string | undefined;
|
|
24
|
+
satellite?: Partial<import("../types/satellite.types").Satellite> | undefined;
|
|
25
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { User } from '../types/auth.types';
|
|
2
|
+
import { Store } from './store';
|
|
3
|
+
export declare class AuthStore extends Store<User | null> {
|
|
4
|
+
private static instance;
|
|
5
|
+
private authUser;
|
|
6
|
+
private constructor();
|
|
7
|
+
static getInstance(): AuthStore;
|
|
8
|
+
set(authUser: User | null): void;
|
|
9
|
+
get(): User | null;
|
|
10
|
+
subscribe(callback: (data: User | null) => void): () => void;
|
|
11
|
+
isLoggedIn(): boolean;
|
|
12
|
+
reset(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Environment } from '../types/env.types';
|
|
2
|
+
import { Store } from './store';
|
|
3
|
+
export declare class EnvStore extends Store<Environment | undefined> {
|
|
4
|
+
private static instance;
|
|
5
|
+
private env;
|
|
6
|
+
private constructor();
|
|
7
|
+
static getInstance(): EnvStore;
|
|
8
|
+
set(env: Environment | undefined): void;
|
|
9
|
+
get(): Environment | undefined;
|
|
10
|
+
localIdentity(): boolean;
|
|
11
|
+
subscribe(callback: (data: Environment | null | undefined) => void): () => void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Principal } from '@dfinity/principal';
|
|
2
|
+
import type { Doc } from './doc.types';
|
|
3
|
+
export interface UserData {
|
|
4
|
+
principal: Principal;
|
|
5
|
+
created_at: Date | number | bigint;
|
|
6
|
+
updated_at: Date | number | bigint;
|
|
7
|
+
}
|
|
8
|
+
export type User = Doc<UserData>;
|
|
9
|
+
export interface SignInOptions {
|
|
10
|
+
maxTimeToLive?: bigint;
|
|
11
|
+
derivationOrigin?: string | URL;
|
|
12
|
+
windowOpenerFeatures?: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ListResults<T> {
|
|
2
|
+
items: T[];
|
|
3
|
+
length: bigint;
|
|
4
|
+
matches_length: bigint;
|
|
5
|
+
}
|
|
6
|
+
export interface PaginateDocs {
|
|
7
|
+
startAfter?: string;
|
|
8
|
+
limit?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface OrderDocs {
|
|
11
|
+
desc: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface ListParams {
|
|
14
|
+
matcher?: string;
|
|
15
|
+
paginate?: PaginateDocs;
|
|
16
|
+
order?: OrderDocs;
|
|
17
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AssetNoContent } from '../../../declarations/satellite/satellite.did';
|
|
2
|
+
import type { ListResults } from './list.types';
|
|
3
|
+
export interface AssetEncoding {
|
|
4
|
+
modified: bigint;
|
|
5
|
+
sha256: string;
|
|
6
|
+
total_length: bigint;
|
|
7
|
+
}
|
|
8
|
+
export interface AssetKey {
|
|
9
|
+
fullPath: string;
|
|
10
|
+
name: string;
|
|
11
|
+
downloadUrl: string;
|
|
12
|
+
}
|
|
13
|
+
export type ENCODING_TYPE = 'identity' | 'gzip' | 'compress' | 'deflate' | 'br';
|
|
14
|
+
export interface Asset extends AssetKey {
|
|
15
|
+
token?: string;
|
|
16
|
+
headers: [string, string][];
|
|
17
|
+
encodings: Record<ENCODING_TYPE, AssetEncoding>;
|
|
18
|
+
}
|
|
19
|
+
export interface Assets extends Pick<ListResults<AssetNoContent>, 'length' | 'matches_length'> {
|
|
20
|
+
assets: Asset[];
|
|
21
|
+
}
|
|
22
|
+
export interface Storage {
|
|
23
|
+
filename: string;
|
|
24
|
+
data: Blob;
|
|
25
|
+
collection: string;
|
|
26
|
+
fullPath?: string;
|
|
27
|
+
headers?: [string, string][];
|
|
28
|
+
token?: string;
|
|
29
|
+
encoding?: ENCODING_TYPE;
|
|
30
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ActorMethod, ActorSubclass } from '@dfinity/agent';
|
|
2
|
+
import type { IDL } from '@dfinity/candid';
|
|
3
|
+
import type { Satellite } from '../types/satellite.types';
|
|
4
|
+
export declare const createActor: <T = Record<string, ActorMethod<unknown[], unknown>>>({ satelliteId: canisterId, idlFactory, identity, fetch, env }: {
|
|
5
|
+
idlFactory: IDL.InterfaceFactory;
|
|
6
|
+
} & Required<Pick<Satellite, "satelliteId" | "identity">> & Pick<Satellite, "fetch" | "env">) => Promise<ActorSubclass<T>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sha256ToBase64String: (sha256: Iterable<number>) => string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const toNullable: <T>(value?: T | undefined) => [] | [T];
|
|
2
|
+
export declare const fromNullable: <T>(value: [] | [T]) => T | undefined;
|
|
3
|
+
export declare const toArray: <T>(data: T) => Promise<Uint8Array>;
|
|
4
|
+
export declare const fromArray: <T>(data: Uint8Array) => Promise<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ListParams } from '../types/list.types';
|
|
2
|
+
export declare const toListParams: ({ matcher, paginate, order }: ListParams) => {
|
|
3
|
+
matcher: [] | [string];
|
|
4
|
+
paginate: [] | [{
|
|
5
|
+
start_after: [] | [string];
|
|
6
|
+
limit: [] | [bigint];
|
|
7
|
+
}];
|
|
8
|
+
order: [] | [import("../types/list.types").OrderDocs];
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const encodeFilename: (filename: string) => string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Is null or undefined */
|
|
2
|
+
export declare const isNullish: <T>(argument: T | null | undefined) => argument is null | undefined;
|
|
3
|
+
/** Not null and not undefined */
|
|
4
|
+
export declare const nonNullish: <T>(argument: T | null | undefined) => argument is NonNullable<T>;
|
|
5
|
+
export declare class NullishError extends Error {
|
|
6
|
+
}
|
|
7
|
+
export declare const assertNonNullish: <T>(value: T, message?: string) => asserts value is NonNullable<T>;
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@junobuild/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "JavaScript core client for Juno",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/cjs/index.cjs.js",
|
|
7
|
+
"module": "dist/esm/index.js",
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"rmdir": "node ../../scripts/rmdir.mjs",
|
|
16
|
+
"ts-declaration": "tsc --emitDeclarationOnly --outDir dist/types",
|
|
17
|
+
"build": "npm run rmdir && mkdir -p dist && node esbuild.mjs && npm run ts-declaration",
|
|
18
|
+
"prepack": "npm run build"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/buildwithjuno/juno-js.git",
|
|
23
|
+
"directory": "packages/core"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/buildwithjuno/juno-js"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"blockchain-as-a-service",
|
|
30
|
+
"baas",
|
|
31
|
+
"dapps",
|
|
32
|
+
"dapps-development",
|
|
33
|
+
"internet computer",
|
|
34
|
+
"smart-contracts",
|
|
35
|
+
"web3"
|
|
36
|
+
],
|
|
37
|
+
"homepage": "https://juno.build"
|
|
38
|
+
}
|