@junobuild/analytics 0.0.8 → 0.0.10
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/declarations/index/index.d.ts +45 -0
- package/declarations/index/index.did +68 -0
- package/declarations/index/index.did.d.ts +97 -0
- package/declarations/index/index.factory.did.js +94 -0
- package/declarations/index/index.js +37 -0
- package/declarations/orbiter/orbiter.did.d.ts +9 -6
- package/declarations/orbiter/orbiter.factory.did.js +12 -9
- package/dist/browser/idb.services-V6IDWAXJ.js +2 -0
- package/dist/browser/{idb.services-T4DLYFZI.js.map → idb.services-V6IDWAXJ.js.map} +3 -3
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +2 -2
- package/dist/declarations/index/index.d.ts +45 -0
- package/dist/declarations/index/index.did +68 -0
- package/dist/declarations/index/index.did.d.ts +97 -0
- package/dist/declarations/index/index.factory.did.js +94 -0
- package/dist/declarations/index/index.js +37 -0
- package/dist/declarations/orbiter/orbiter.did.d.ts +9 -6
- package/dist/declarations/orbiter/orbiter.factory.did.js +12 -9
- package/dist/node/index.mjs +1 -1
- package/dist/node/index.mjs.map +3 -3
- package/dist/types/services/idb.services.d.ts +5 -7
- package/dist/types/types/idb.d.ts +7 -5
- package/dist/workers/analytics.worker.js +10 -10
- package/dist/workers/analytics.worker.js.gz +0 -0
- package/dist/workers/analytics.worker.js.map +3 -3
- package/package.json +1 -1
- package/dist/browser/idb.services-T4DLYFZI.js +0 -2
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type {ActorConfig, ActorSubclass, Agent, HttpAgentOptions} from '@dfinity/agent';
|
|
2
|
+
import type {IDL} from '@dfinity/candid';
|
|
3
|
+
import type {Principal} from '@dfinity/principal';
|
|
4
|
+
|
|
5
|
+
import {_SERVICE} from './index.did';
|
|
6
|
+
|
|
7
|
+
export declare const idlFactory: IDL.InterfaceFactory;
|
|
8
|
+
export declare const canisterId: string;
|
|
9
|
+
|
|
10
|
+
export declare interface CreateActorOptions {
|
|
11
|
+
/**
|
|
12
|
+
* @see {@link Agent}
|
|
13
|
+
*/
|
|
14
|
+
agent?: Agent;
|
|
15
|
+
/**
|
|
16
|
+
* @see {@link HttpAgentOptions}
|
|
17
|
+
*/
|
|
18
|
+
agentOptions?: HttpAgentOptions;
|
|
19
|
+
/**
|
|
20
|
+
* @see {@link ActorConfig}
|
|
21
|
+
*/
|
|
22
|
+
actorOptions?: ActorConfig;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister.
|
|
27
|
+
* @constructs {@link ActorSubClass}
|
|
28
|
+
* @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to
|
|
29
|
+
* @param {CreateActorOptions} options - see {@link CreateActorOptions}
|
|
30
|
+
* @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions
|
|
31
|
+
* @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent
|
|
32
|
+
* @see {@link HttpAgentOptions}
|
|
33
|
+
* @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor
|
|
34
|
+
* @see {@link ActorConfig}
|
|
35
|
+
*/
|
|
36
|
+
export declare const createActor: (
|
|
37
|
+
canisterId: string | Principal,
|
|
38
|
+
options?: CreateActorOptions
|
|
39
|
+
) => ActorSubclass<_SERVICE>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Intialized Actor using default settings, ready to talk to a canister using its candid interface
|
|
43
|
+
* @constructs {@link ActorSubClass}
|
|
44
|
+
*/
|
|
45
|
+
export declare const index: ActorSubclass<_SERVICE>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
type GetAccountIdentifierTransactionsArgs = record {
|
|
2
|
+
max_results : nat64;
|
|
3
|
+
start : opt nat64;
|
|
4
|
+
account_identifier : text;
|
|
5
|
+
};
|
|
6
|
+
type GetAccountIdentifierTransactionsError = record { message : text };
|
|
7
|
+
type GetAccountIdentifierTransactionsResponse = record {
|
|
8
|
+
balance : nat64;
|
|
9
|
+
transactions : vec TransactionWithId;
|
|
10
|
+
oldest_tx_id : opt nat64;
|
|
11
|
+
};
|
|
12
|
+
type GetBlocksRequest = record { start : nat; length : nat };
|
|
13
|
+
type GetBlocksResponse = record { blocks : vec vec nat8; chain_length : nat64 };
|
|
14
|
+
type HttpRequest = record {
|
|
15
|
+
url : text;
|
|
16
|
+
method : text;
|
|
17
|
+
body : vec nat8;
|
|
18
|
+
headers : vec record { text; text };
|
|
19
|
+
};
|
|
20
|
+
type HttpResponse = record {
|
|
21
|
+
body : vec nat8;
|
|
22
|
+
headers : vec record { text; text };
|
|
23
|
+
status_code : nat16;
|
|
24
|
+
};
|
|
25
|
+
type InitArg = record { ledger_id : principal };
|
|
26
|
+
type Operation = variant {
|
|
27
|
+
Approve : record {
|
|
28
|
+
fee : Tokens;
|
|
29
|
+
from : text;
|
|
30
|
+
allowance : Tokens;
|
|
31
|
+
expires_at : opt TimeStamp;
|
|
32
|
+
spender : text;
|
|
33
|
+
};
|
|
34
|
+
Burn : record { from : text; amount : Tokens };
|
|
35
|
+
Mint : record { to : text; amount : Tokens };
|
|
36
|
+
Transfer : record { to : text; fee : Tokens; from : text; amount : Tokens };
|
|
37
|
+
TransferFrom : record {
|
|
38
|
+
to : text;
|
|
39
|
+
fee : Tokens;
|
|
40
|
+
from : text;
|
|
41
|
+
amount : Tokens;
|
|
42
|
+
spender : text;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
type Result = variant {
|
|
46
|
+
Ok : GetAccountIdentifierTransactionsResponse;
|
|
47
|
+
Err : GetAccountIdentifierTransactionsError;
|
|
48
|
+
};
|
|
49
|
+
type Status = record { num_blocks_synced : nat64 };
|
|
50
|
+
type TimeStamp = record { timestamp_nanos : nat64 };
|
|
51
|
+
type Tokens = record { e8s : nat64 };
|
|
52
|
+
type Transaction = record {
|
|
53
|
+
memo : nat64;
|
|
54
|
+
icrc1_memo : opt vec nat8;
|
|
55
|
+
operation : Operation;
|
|
56
|
+
created_at_time : opt TimeStamp;
|
|
57
|
+
};
|
|
58
|
+
type TransactionWithId = record { id : nat64; transaction : Transaction };
|
|
59
|
+
service : (InitArg) -> {
|
|
60
|
+
get_account_identifier_balance : (text) -> (nat64) query;
|
|
61
|
+
get_account_identifier_transactions : (
|
|
62
|
+
GetAccountIdentifierTransactionsArgs,
|
|
63
|
+
) -> (Result) query;
|
|
64
|
+
get_blocks : (GetBlocksRequest) -> (GetBlocksResponse) query;
|
|
65
|
+
http_request : (HttpRequest) -> (HttpResponse) query;
|
|
66
|
+
ledger_id : () -> (principal) query;
|
|
67
|
+
status : () -> (Status) query;
|
|
68
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type {ActorMethod} from '@dfinity/agent';
|
|
2
|
+
import type {Principal} from '@dfinity/principal';
|
|
3
|
+
|
|
4
|
+
export interface GetAccountIdentifierTransactionsArgs {
|
|
5
|
+
max_results: bigint;
|
|
6
|
+
start: [] | [bigint];
|
|
7
|
+
account_identifier: string;
|
|
8
|
+
}
|
|
9
|
+
export interface GetAccountIdentifierTransactionsError {
|
|
10
|
+
message: string;
|
|
11
|
+
}
|
|
12
|
+
export interface GetAccountIdentifierTransactionsResponse {
|
|
13
|
+
balance: bigint;
|
|
14
|
+
transactions: Array<TransactionWithId>;
|
|
15
|
+
oldest_tx_id: [] | [bigint];
|
|
16
|
+
}
|
|
17
|
+
export interface GetBlocksRequest {
|
|
18
|
+
start: bigint;
|
|
19
|
+
length: bigint;
|
|
20
|
+
}
|
|
21
|
+
export interface GetBlocksResponse {
|
|
22
|
+
blocks: Array<Uint8Array | number[]>;
|
|
23
|
+
chain_length: bigint;
|
|
24
|
+
}
|
|
25
|
+
export interface HttpRequest {
|
|
26
|
+
url: string;
|
|
27
|
+
method: string;
|
|
28
|
+
body: Uint8Array | number[];
|
|
29
|
+
headers: Array<[string, string]>;
|
|
30
|
+
}
|
|
31
|
+
export interface HttpResponse {
|
|
32
|
+
body: Uint8Array | number[];
|
|
33
|
+
headers: Array<[string, string]>;
|
|
34
|
+
status_code: number;
|
|
35
|
+
}
|
|
36
|
+
export interface InitArg {
|
|
37
|
+
ledger_id: Principal;
|
|
38
|
+
}
|
|
39
|
+
export type Operation =
|
|
40
|
+
| {
|
|
41
|
+
Approve: {
|
|
42
|
+
fee: Tokens;
|
|
43
|
+
from: string;
|
|
44
|
+
allowance: Tokens;
|
|
45
|
+
expires_at: [] | [TimeStamp];
|
|
46
|
+
spender: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
| {Burn: {from: string; amount: Tokens}}
|
|
50
|
+
| {Mint: {to: string; amount: Tokens}}
|
|
51
|
+
| {
|
|
52
|
+
Transfer: {
|
|
53
|
+
to: string;
|
|
54
|
+
fee: Tokens;
|
|
55
|
+
from: string;
|
|
56
|
+
amount: Tokens;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
| {
|
|
60
|
+
TransferFrom: {
|
|
61
|
+
to: string;
|
|
62
|
+
fee: Tokens;
|
|
63
|
+
from: string;
|
|
64
|
+
amount: Tokens;
|
|
65
|
+
spender: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
export type Result =
|
|
69
|
+
| {Ok: GetAccountIdentifierTransactionsResponse}
|
|
70
|
+
| {Err: GetAccountIdentifierTransactionsError};
|
|
71
|
+
export interface Status {
|
|
72
|
+
num_blocks_synced: bigint;
|
|
73
|
+
}
|
|
74
|
+
export interface TimeStamp {
|
|
75
|
+
timestamp_nanos: bigint;
|
|
76
|
+
}
|
|
77
|
+
export interface Tokens {
|
|
78
|
+
e8s: bigint;
|
|
79
|
+
}
|
|
80
|
+
export interface Transaction {
|
|
81
|
+
memo: bigint;
|
|
82
|
+
icrc1_memo: [] | [Uint8Array | number[]];
|
|
83
|
+
operation: Operation;
|
|
84
|
+
created_at_time: [] | [TimeStamp];
|
|
85
|
+
}
|
|
86
|
+
export interface TransactionWithId {
|
|
87
|
+
id: bigint;
|
|
88
|
+
transaction: Transaction;
|
|
89
|
+
}
|
|
90
|
+
export interface _SERVICE {
|
|
91
|
+
get_account_identifier_balance: ActorMethod<[string], bigint>;
|
|
92
|
+
get_account_identifier_transactions: ActorMethod<[GetAccountIdentifierTransactionsArgs], Result>;
|
|
93
|
+
get_blocks: ActorMethod<[GetBlocksRequest], GetBlocksResponse>;
|
|
94
|
+
http_request: ActorMethod<[HttpRequest], HttpResponse>;
|
|
95
|
+
ledger_id: ActorMethod<[], Principal>;
|
|
96
|
+
status: ActorMethod<[], Status>;
|
|
97
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
export const idlFactory = ({IDL}) => {
|
|
3
|
+
const InitArg = IDL.Record({ledger_id: IDL.Principal});
|
|
4
|
+
const GetAccountIdentifierTransactionsArgs = IDL.Record({
|
|
5
|
+
max_results: IDL.Nat64,
|
|
6
|
+
start: IDL.Opt(IDL.Nat64),
|
|
7
|
+
account_identifier: IDL.Text
|
|
8
|
+
});
|
|
9
|
+
const Tokens = IDL.Record({e8s: IDL.Nat64});
|
|
10
|
+
const TimeStamp = IDL.Record({timestamp_nanos: IDL.Nat64});
|
|
11
|
+
const Operation = IDL.Variant({
|
|
12
|
+
Approve: IDL.Record({
|
|
13
|
+
fee: Tokens,
|
|
14
|
+
from: IDL.Text,
|
|
15
|
+
allowance: Tokens,
|
|
16
|
+
expires_at: IDL.Opt(TimeStamp),
|
|
17
|
+
spender: IDL.Text
|
|
18
|
+
}),
|
|
19
|
+
Burn: IDL.Record({from: IDL.Text, amount: Tokens}),
|
|
20
|
+
Mint: IDL.Record({to: IDL.Text, amount: Tokens}),
|
|
21
|
+
Transfer: IDL.Record({
|
|
22
|
+
to: IDL.Text,
|
|
23
|
+
fee: Tokens,
|
|
24
|
+
from: IDL.Text,
|
|
25
|
+
amount: Tokens
|
|
26
|
+
}),
|
|
27
|
+
TransferFrom: IDL.Record({
|
|
28
|
+
to: IDL.Text,
|
|
29
|
+
fee: Tokens,
|
|
30
|
+
from: IDL.Text,
|
|
31
|
+
amount: Tokens,
|
|
32
|
+
spender: IDL.Text
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
const Transaction = IDL.Record({
|
|
36
|
+
memo: IDL.Nat64,
|
|
37
|
+
icrc1_memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
38
|
+
operation: Operation,
|
|
39
|
+
created_at_time: IDL.Opt(TimeStamp)
|
|
40
|
+
});
|
|
41
|
+
const TransactionWithId = IDL.Record({
|
|
42
|
+
id: IDL.Nat64,
|
|
43
|
+
transaction: Transaction
|
|
44
|
+
});
|
|
45
|
+
const GetAccountIdentifierTransactionsResponse = IDL.Record({
|
|
46
|
+
balance: IDL.Nat64,
|
|
47
|
+
transactions: IDL.Vec(TransactionWithId),
|
|
48
|
+
oldest_tx_id: IDL.Opt(IDL.Nat64)
|
|
49
|
+
});
|
|
50
|
+
const GetAccountIdentifierTransactionsError = IDL.Record({
|
|
51
|
+
message: IDL.Text
|
|
52
|
+
});
|
|
53
|
+
const Result = IDL.Variant({
|
|
54
|
+
Ok: GetAccountIdentifierTransactionsResponse,
|
|
55
|
+
Err: GetAccountIdentifierTransactionsError
|
|
56
|
+
});
|
|
57
|
+
const GetBlocksRequest = IDL.Record({
|
|
58
|
+
start: IDL.Nat,
|
|
59
|
+
length: IDL.Nat
|
|
60
|
+
});
|
|
61
|
+
const GetBlocksResponse = IDL.Record({
|
|
62
|
+
blocks: IDL.Vec(IDL.Vec(IDL.Nat8)),
|
|
63
|
+
chain_length: IDL.Nat64
|
|
64
|
+
});
|
|
65
|
+
const HttpRequest = IDL.Record({
|
|
66
|
+
url: IDL.Text,
|
|
67
|
+
method: IDL.Text,
|
|
68
|
+
body: IDL.Vec(IDL.Nat8),
|
|
69
|
+
headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))
|
|
70
|
+
});
|
|
71
|
+
const HttpResponse = IDL.Record({
|
|
72
|
+
body: IDL.Vec(IDL.Nat8),
|
|
73
|
+
headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
74
|
+
status_code: IDL.Nat16
|
|
75
|
+
});
|
|
76
|
+
const Status = IDL.Record({num_blocks_synced: IDL.Nat64});
|
|
77
|
+
return IDL.Service({
|
|
78
|
+
get_account_identifier_balance: IDL.Func([IDL.Text], [IDL.Nat64], ['query']),
|
|
79
|
+
get_account_identifier_transactions: IDL.Func(
|
|
80
|
+
[GetAccountIdentifierTransactionsArgs],
|
|
81
|
+
[Result],
|
|
82
|
+
['query']
|
|
83
|
+
),
|
|
84
|
+
get_blocks: IDL.Func([GetBlocksRequest], [GetBlocksResponse], ['query']),
|
|
85
|
+
http_request: IDL.Func([HttpRequest], [HttpResponse], ['query']),
|
|
86
|
+
ledger_id: IDL.Func([], [IDL.Principal], ['query']),
|
|
87
|
+
status: IDL.Func([], [Status], ['query'])
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
export const init = ({IDL}) => {
|
|
92
|
+
const InitArg = IDL.Record({ledger_id: IDL.Principal});
|
|
93
|
+
return [InitArg];
|
|
94
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {Actor, HttpAgent} from '@dfinity/agent';
|
|
2
|
+
|
|
3
|
+
// Imports and re-exports candid interface
|
|
4
|
+
import {idlFactory} from './index.did.js';
|
|
5
|
+
export {idlFactory} from './index.did.js';
|
|
6
|
+
|
|
7
|
+
/* CANISTER_ID is replaced by webpack based on node environment
|
|
8
|
+
* Note: canister environment variable will be standardized as
|
|
9
|
+
* process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
|
|
10
|
+
* beginning in dfx 0.15.0
|
|
11
|
+
*/
|
|
12
|
+
export const canisterId = process.env.CANISTER_ID_INDEX || process.env.INDEX_CANISTER_ID;
|
|
13
|
+
|
|
14
|
+
export const createActor = (canisterId, options = {}) => {
|
|
15
|
+
const agent = options.agent || new HttpAgent({...options.agentOptions});
|
|
16
|
+
|
|
17
|
+
if (options.agent && options.agentOptions) {
|
|
18
|
+
console.warn(
|
|
19
|
+
'Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent.'
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Fetch root key for certificate validation during development
|
|
24
|
+
if (process.env.DFX_NETWORK !== 'ic') {
|
|
25
|
+
agent.fetchRootKey().catch((err) => {
|
|
26
|
+
console.warn('Unable to fetch root key. Check to ensure that your local replica is running');
|
|
27
|
+
console.error(err);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Creates an actor with using the candid interface and the HttpAgent
|
|
32
|
+
return Actor.createActor(idlFactory, {
|
|
33
|
+
agent,
|
|
34
|
+
canisterId,
|
|
35
|
+
...options.actorOptions
|
|
36
|
+
});
|
|
37
|
+
};
|
|
@@ -3,8 +3,7 @@ import type {Principal} from '@dfinity/principal';
|
|
|
3
3
|
|
|
4
4
|
export interface AnalyticKey {
|
|
5
5
|
key: string;
|
|
6
|
-
|
|
7
|
-
satellite_id: Principal;
|
|
6
|
+
collected_at: bigint;
|
|
8
7
|
}
|
|
9
8
|
export interface Controller {
|
|
10
9
|
updated_at: bigint;
|
|
@@ -30,11 +29,12 @@ export interface PageView {
|
|
|
30
29
|
updated_at: bigint;
|
|
31
30
|
referrer: [] | [string];
|
|
32
31
|
time_zone: string;
|
|
32
|
+
session_id: string;
|
|
33
33
|
href: string;
|
|
34
34
|
created_at: bigint;
|
|
35
|
+
satellite_id: Principal;
|
|
35
36
|
device: PageViewDevice;
|
|
36
37
|
user_agent: [] | [string];
|
|
37
|
-
collected_at: bigint;
|
|
38
38
|
}
|
|
39
39
|
export interface PageViewDevice {
|
|
40
40
|
inner_height: number;
|
|
@@ -62,10 +62,11 @@ export interface SetPageView {
|
|
|
62
62
|
updated_at: [] | [bigint];
|
|
63
63
|
referrer: [] | [string];
|
|
64
64
|
time_zone: string;
|
|
65
|
+
session_id: string;
|
|
65
66
|
href: string;
|
|
67
|
+
satellite_id: Principal;
|
|
66
68
|
device: PageViewDevice;
|
|
67
69
|
user_agent: [] | [string];
|
|
68
|
-
collected_at: bigint;
|
|
69
70
|
}
|
|
70
71
|
export interface SetSatelliteConfig {
|
|
71
72
|
updated_at: [] | [bigint];
|
|
@@ -73,17 +74,19 @@ export interface SetSatelliteConfig {
|
|
|
73
74
|
}
|
|
74
75
|
export interface SetTrackEvent {
|
|
75
76
|
updated_at: [] | [bigint];
|
|
77
|
+
session_id: string;
|
|
76
78
|
metadata: [] | [Array<[string, string]>];
|
|
77
79
|
name: string;
|
|
80
|
+
satellite_id: Principal;
|
|
78
81
|
user_agent: [] | [string];
|
|
79
|
-
collected_at: bigint;
|
|
80
82
|
}
|
|
81
83
|
export interface TrackEvent {
|
|
82
84
|
updated_at: bigint;
|
|
85
|
+
session_id: string;
|
|
83
86
|
metadata: [] | [Array<[string, string]>];
|
|
84
87
|
name: string;
|
|
85
88
|
created_at: bigint;
|
|
86
|
-
|
|
89
|
+
satellite_id: Principal;
|
|
87
90
|
}
|
|
88
91
|
export interface _SERVICE {
|
|
89
92
|
del_controllers: ActorMethod<[DeleteControllersArgs], Array<[Principal, Controller]>>;
|
|
@@ -22,8 +22,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
22
22
|
});
|
|
23
23
|
const AnalyticKey = IDL.Record({
|
|
24
24
|
key: IDL.Text,
|
|
25
|
-
|
|
26
|
-
satellite_id: IDL.Principal
|
|
25
|
+
collected_at: IDL.Nat64
|
|
27
26
|
});
|
|
28
27
|
const PageViewDevice = IDL.Record({
|
|
29
28
|
inner_height: IDL.Nat16,
|
|
@@ -34,18 +33,20 @@ export const idlFactory = ({IDL}) => {
|
|
|
34
33
|
updated_at: IDL.Nat64,
|
|
35
34
|
referrer: IDL.Opt(IDL.Text),
|
|
36
35
|
time_zone: IDL.Text,
|
|
36
|
+
session_id: IDL.Text,
|
|
37
37
|
href: IDL.Text,
|
|
38
38
|
created_at: IDL.Nat64,
|
|
39
|
+
satellite_id: IDL.Principal,
|
|
39
40
|
device: PageViewDevice,
|
|
40
|
-
user_agent: IDL.Opt(IDL.Text)
|
|
41
|
-
collected_at: IDL.Nat64
|
|
41
|
+
user_agent: IDL.Opt(IDL.Text)
|
|
42
42
|
});
|
|
43
43
|
const TrackEvent = IDL.Record({
|
|
44
44
|
updated_at: IDL.Nat64,
|
|
45
|
+
session_id: IDL.Text,
|
|
45
46
|
metadata: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))),
|
|
46
47
|
name: IDL.Text,
|
|
47
48
|
created_at: IDL.Nat64,
|
|
48
|
-
|
|
49
|
+
satellite_id: IDL.Principal
|
|
49
50
|
});
|
|
50
51
|
const SatelliteConfig = IDL.Record({
|
|
51
52
|
updated_at: IDL.Nat64,
|
|
@@ -66,10 +67,11 @@ export const idlFactory = ({IDL}) => {
|
|
|
66
67
|
updated_at: IDL.Opt(IDL.Nat64),
|
|
67
68
|
referrer: IDL.Opt(IDL.Text),
|
|
68
69
|
time_zone: IDL.Text,
|
|
70
|
+
session_id: IDL.Text,
|
|
69
71
|
href: IDL.Text,
|
|
72
|
+
satellite_id: IDL.Principal,
|
|
70
73
|
device: PageViewDevice,
|
|
71
|
-
user_agent: IDL.Opt(IDL.Text)
|
|
72
|
-
collected_at: IDL.Nat64
|
|
74
|
+
user_agent: IDL.Opt(IDL.Text)
|
|
73
75
|
});
|
|
74
76
|
const Result = IDL.Variant({Ok: PageView, Err: IDL.Text});
|
|
75
77
|
const Result_1 = IDL.Variant({
|
|
@@ -82,10 +84,11 @@ export const idlFactory = ({IDL}) => {
|
|
|
82
84
|
});
|
|
83
85
|
const SetTrackEvent = IDL.Record({
|
|
84
86
|
updated_at: IDL.Opt(IDL.Nat64),
|
|
87
|
+
session_id: IDL.Text,
|
|
85
88
|
metadata: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))),
|
|
86
89
|
name: IDL.Text,
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
satellite_id: IDL.Principal,
|
|
91
|
+
user_agent: IDL.Opt(IDL.Text)
|
|
89
92
|
});
|
|
90
93
|
const Result_2 = IDL.Variant({Ok: TrackEvent, Err: IDL.Text});
|
|
91
94
|
return IDL.Service({
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function o(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function a(e,t){let n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);let r=o(n);return(i,u)=>r.then(c=>u(c.transaction(t,i).objectStore(t)))}var s;function l(){return s||(s=a("keyval-store","keyval")),s}function d(e,t,n=l()){return n("readwrite",r=>(r.put(t,e),o(r.transaction)))}function y(e,t=l()){return t("readwrite",n=>(e.forEach(r=>n.delete(r)),o(n.transaction)))}function v(e,t){return e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},o(e.transaction)}function f(e=l()){return e("readonly",t=>{if(t.getAll&&t.getAllKeys)return Promise.all([o(t.getAllKeys()),o(t.getAll())]).then(([r,i])=>r.map((u,c)=>[u,i[c]]));let n=[];return e("readonly",r=>v(r,i=>n.push([i.key,i.value])).then(()=>n))})}var p=a("juno-views","views"),g=a("juno-events","events"),h=({key:e,view:t})=>d(e,t,p),P=()=>f(p),b=e=>y(e,p),k=({key:e,track:t})=>d(e,t,g),I=()=>f(g),K=e=>y(e,g);export{b as delPageViews,K as delTrackEvents,P as getPageViews,I as getTrackEvents,h as setPageView,k as setTrackEvent};
|
|
2
|
+
//# sourceMappingURL=idb.services-V6IDWAXJ.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../node_modules/idb-keyval/dist/index.js", "../../src/services/idb.services.ts"],
|
|
4
|
-
"sourcesContent": ["function promisifyRequest(request) {\n return new Promise((resolve, reject) => {\n // @ts-ignore - file size hacks\n request.oncomplete = request.onsuccess = () => resolve(request.result);\n // @ts-ignore - file size hacks\n request.onabort = request.onerror = () => reject(request.error);\n });\n}\nfunction createStore(dbName, storeName) {\n const request = indexedDB.open(dbName);\n request.onupgradeneeded = () => request.result.createObjectStore(storeName);\n const dbp = promisifyRequest(request);\n return (txMode, callback) => dbp.then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName)));\n}\nlet defaultGetStoreFunc;\nfunction defaultGetStore() {\n if (!defaultGetStoreFunc) {\n defaultGetStoreFunc = createStore('keyval-store', 'keyval');\n }\n return defaultGetStoreFunc;\n}\n/**\n * Get a value by its key.\n *\n * @param key\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction get(key, customStore = defaultGetStore()) {\n return customStore('readonly', (store) => promisifyRequest(store.get(key)));\n}\n/**\n * Set a value with a key.\n *\n * @param key\n * @param value\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction set(key, value, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.put(value, key);\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Set multiple values at once. This is faster than calling set() multiple times.\n * It's also atomic \u2013 if one of the pairs can't be added, none will be added.\n *\n * @param entries Array of entries, where each entry is an array of `[key, value]`.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction setMany(entries, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n entries.forEach((entry) => store.put(entry[1], entry[0]));\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Get multiple values by their keys\n *\n * @param keys\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction getMany(keys, customStore = defaultGetStore()) {\n return customStore('readonly', (store) => Promise.all(keys.map((key) => promisifyRequest(store.get(key)))));\n}\n/**\n * Update a value. This lets you see the old value and update it as an atomic operation.\n *\n * @param key\n * @param updater A callback that takes the old value and returns a new value.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction update(key, updater, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => \n // Need to create the promise manually.\n // If I try to chain promises, the transaction closes in browsers\n // that use a promise polyfill (IE10/11).\n new Promise((resolve, reject) => {\n store.get(key).onsuccess = function () {\n try {\n store.put(updater(this.result), key);\n resolve(promisifyRequest(store.transaction));\n }\n catch (err) {\n reject(err);\n }\n };\n }));\n}\n/**\n * Delete a particular key from the store.\n *\n * @param key\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction del(key, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.delete(key);\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Delete multiple keys at once.\n *\n * @param keys List of keys to delete.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction delMany(keys, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n keys.forEach((key) => store.delete(key));\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Clear all values in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction clear(customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.clear();\n return promisifyRequest(store.transaction);\n });\n}\nfunction eachCursor(store, callback) {\n store.openCursor().onsuccess = function () {\n if (!this.result)\n return;\n callback(this.result);\n this.result.continue();\n };\n return promisifyRequest(store.transaction);\n}\n/**\n * Get all keys in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction keys(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n if (store.getAllKeys) {\n return promisifyRequest(store.getAllKeys());\n }\n const items = [];\n return eachCursor(store, (cursor) => items.push(cursor.key)).then(() => items);\n });\n}\n/**\n * Get all values in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction values(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n if (store.getAll) {\n return promisifyRequest(store.getAll());\n }\n const items = [];\n return eachCursor(store, (cursor) => items.push(cursor.value)).then(() => items);\n });\n}\n/**\n * Get all entries in the store. Each entry is an array of `[key, value]`.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction entries(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n // (although, hopefully we'll get a simpler path some day)\n if (store.getAll && store.getAllKeys) {\n return Promise.all([\n promisifyRequest(store.getAllKeys()),\n promisifyRequest(store.getAll()),\n ]).then(([keys, values]) => keys.map((key, i) => [key, values[i]]));\n }\n const items = [];\n return customStore('readonly', (store) => eachCursor(store, (cursor) => items.push([cursor.key, cursor.value])).then(() => items));\n });\n}\n\nexport { clear, createStore, del, delMany, entries, get, getMany, keys, promisifyRequest, set, setMany, update, values };\n", "import {createStore, delMany, entries, set} from 'idb-keyval';\nimport type {
|
|
5
|
-
"mappings": "AAAA,SAASA,EAAiBC,EAAS,CAC/B,OAAO,IAAI,QAAQ,CAACC,EAASC,IAAW,CAEpCF,EAAQ,WAAaA,EAAQ,UAAY,IAAMC,EAAQD,EAAQ,MAAM,EAErEA,EAAQ,QAAUA,EAAQ,QAAU,IAAME,EAAOF,EAAQ,KAAK,CAClE,CAAC,CACL,CACA,SAASG,EAAYC,EAAQC,EAAW,CACpC,IAAML,EAAU,UAAU,KAAKI,CAAM,EACrCJ,EAAQ,gBAAkB,IAAMA,EAAQ,OAAO,kBAAkBK,CAAS,EAC1E,IAAMC,EAAMP,EAAiBC,CAAO,EACpC,MAAO,CAACO,EAAQC,IAAaF,EAAI,KAAMG,GAAOD,EAASC,EAAG,YAAYJ,EAAWE,CAAM,EAAE,YAAYF,CAAS,CAAC,CAAC,CACpH,CACA,IAAIK,EACJ,SAASC,GAAkB,CACvB,OAAKD,IACDA,EAAsBP,EAAY,eAAgB,QAAQ,GAEvDO,CACX,CAiBA,SAASE,EAAIC,EAAKC,EAAOC,EAAcC,EAAgB,EAAG,CACtD,OAAOD,EAAY,YAAcE,IAC7BA,EAAM,IAAIH,EAAOD,CAAG,EACbK,EAAiBD,EAAM,WAAW,EAC5C,CACL,CAiEA,SAASE,EAAQC,EAAMC,EAAcC,EAAgB,EAAG,CACpD,OAAOD,EAAY,YAAcE,IAC7BH,EAAK,QAASI,GAAQD,EAAM,OAAOC,CAAG,CAAC,EAChCC,EAAiBF,EAAM,WAAW,EAC5C,CACL,CAYA,SAASG,EAAWC,EAAOC,EAAU,CACjC,OAAAD,EAAM,WAAW,EAAE,UAAY,UAAY,CAClC,KAAK,SAEVC,EAAS,KAAK,MAAM,EACpB,KAAK,OAAO,SAAS,EACzB,EACOC,EAAiBF,EAAM,WAAW,CAC7C,CAoCA,SAASG,EAAQC,EAAcC,EAAgB,EAAG,CAC9C,OAAOD,EAAY,WAAaE,GAAU,CAGtC,GAAIA,EAAM,QAAUA,EAAM,WACtB,OAAO,QAAQ,IAAI,CACfC,EAAiBD,EAAM,WAAW,CAAC,EACnCC,EAAiBD,EAAM,OAAO,CAAC,CACnC,CAAC,EAAE,KAAK,CAAC,CAACE,EAAMC,CAAM,IAAMD,EAAK,IAAI,CAACE,EAAKC,IAAM,CAACD,EAAKD,EAAOE,CAAC,CAAC,CAAC,CAAC,EAEtE,IAAMC,EAAQ,CAAC,EACf,OAAOR,EAAY,WAAaE,GAAUO,EAAWP,EAAQQ,GAAWF,EAAM,KAAK,CAACE,EAAO,IAAKA,EAAO,KAAK,CAAC,CAAC,EAAE,KAAK,IAAMF,CAAK,CAAC,CACrI,CAAC,CACL,CClLA,IAAMG,EAAaC,EAAY,aAAc,OAAO,EAC9CC,EAAcD,EAAY,cAAe,QAAQ,EAE1CE,EAAc,CAAC,
|
|
6
|
-
"names": ["promisifyRequest", "request", "resolve", "reject", "createStore", "dbName", "storeName", "dbp", "txMode", "callback", "db", "defaultGetStoreFunc", "defaultGetStore", "set", "key", "value", "customStore", "defaultGetStore", "store", "promisifyRequest", "delMany", "keys", "customStore", "defaultGetStore", "store", "key", "promisifyRequest", "eachCursor", "store", "callback", "promisifyRequest", "entries", "customStore", "defaultGetStore", "store", "promisifyRequest", "keys", "values", "key", "i", "items", "eachCursor", "cursor", "viewsStore", "createStore", "eventsStore", "setPageView", "key", "
|
|
4
|
+
"sourcesContent": ["function promisifyRequest(request) {\n return new Promise((resolve, reject) => {\n // @ts-ignore - file size hacks\n request.oncomplete = request.onsuccess = () => resolve(request.result);\n // @ts-ignore - file size hacks\n request.onabort = request.onerror = () => reject(request.error);\n });\n}\nfunction createStore(dbName, storeName) {\n const request = indexedDB.open(dbName);\n request.onupgradeneeded = () => request.result.createObjectStore(storeName);\n const dbp = promisifyRequest(request);\n return (txMode, callback) => dbp.then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName)));\n}\nlet defaultGetStoreFunc;\nfunction defaultGetStore() {\n if (!defaultGetStoreFunc) {\n defaultGetStoreFunc = createStore('keyval-store', 'keyval');\n }\n return defaultGetStoreFunc;\n}\n/**\n * Get a value by its key.\n *\n * @param key\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction get(key, customStore = defaultGetStore()) {\n return customStore('readonly', (store) => promisifyRequest(store.get(key)));\n}\n/**\n * Set a value with a key.\n *\n * @param key\n * @param value\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction set(key, value, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.put(value, key);\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Set multiple values at once. This is faster than calling set() multiple times.\n * It's also atomic \u2013 if one of the pairs can't be added, none will be added.\n *\n * @param entries Array of entries, where each entry is an array of `[key, value]`.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction setMany(entries, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n entries.forEach((entry) => store.put(entry[1], entry[0]));\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Get multiple values by their keys\n *\n * @param keys\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction getMany(keys, customStore = defaultGetStore()) {\n return customStore('readonly', (store) => Promise.all(keys.map((key) => promisifyRequest(store.get(key)))));\n}\n/**\n * Update a value. This lets you see the old value and update it as an atomic operation.\n *\n * @param key\n * @param updater A callback that takes the old value and returns a new value.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction update(key, updater, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => \n // Need to create the promise manually.\n // If I try to chain promises, the transaction closes in browsers\n // that use a promise polyfill (IE10/11).\n new Promise((resolve, reject) => {\n store.get(key).onsuccess = function () {\n try {\n store.put(updater(this.result), key);\n resolve(promisifyRequest(store.transaction));\n }\n catch (err) {\n reject(err);\n }\n };\n }));\n}\n/**\n * Delete a particular key from the store.\n *\n * @param key\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction del(key, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.delete(key);\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Delete multiple keys at once.\n *\n * @param keys List of keys to delete.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction delMany(keys, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n keys.forEach((key) => store.delete(key));\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Clear all values in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction clear(customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.clear();\n return promisifyRequest(store.transaction);\n });\n}\nfunction eachCursor(store, callback) {\n store.openCursor().onsuccess = function () {\n if (!this.result)\n return;\n callback(this.result);\n this.result.continue();\n };\n return promisifyRequest(store.transaction);\n}\n/**\n * Get all keys in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction keys(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n if (store.getAllKeys) {\n return promisifyRequest(store.getAllKeys());\n }\n const items = [];\n return eachCursor(store, (cursor) => items.push(cursor.key)).then(() => items);\n });\n}\n/**\n * Get all values in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction values(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n if (store.getAll) {\n return promisifyRequest(store.getAll());\n }\n const items = [];\n return eachCursor(store, (cursor) => items.push(cursor.value)).then(() => items);\n });\n}\n/**\n * Get all entries in the store. Each entry is an array of `[key, value]`.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction entries(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n // (although, hopefully we'll get a simpler path some day)\n if (store.getAll && store.getAllKeys) {\n return Promise.all([\n promisifyRequest(store.getAllKeys()),\n promisifyRequest(store.getAll()),\n ]).then(([keys, values]) => keys.map((key, i) => [key, values[i]]));\n }\n const items = [];\n return customStore('readonly', (store) => eachCursor(store, (cursor) => items.push([cursor.key, cursor.value])).then(() => items));\n });\n}\n\nexport { clear, createStore, del, delMany, entries, get, getMany, keys, promisifyRequest, set, setMany, update, values };\n", "import {createStore, delMany, entries, set} from 'idb-keyval';\nimport type {IdbKey, IdbPageView, IdbTrackEvent} from '../types/idb';\n\nconst viewsStore = createStore('juno-views', 'views');\nconst eventsStore = createStore('juno-events', 'events');\n\nexport const setPageView = ({key, view}: {key: IdbKey; view: IdbPageView}): Promise<void> =>\n set(key, view, viewsStore);\n\nexport const getPageViews = (): Promise<[IDBValidKey, IdbPageView][]> => entries(viewsStore);\n\nexport const delPageViews = (keys: IDBValidKey[]): Promise<void> => delMany(keys, viewsStore);\n\nexport const setTrackEvent = ({key, track}: {key: IdbKey; track: IdbTrackEvent}): Promise<void> =>\n set(key, track, eventsStore);\n\nexport const getTrackEvents = (): Promise<[IDBValidKey, IdbTrackEvent][]> => entries(eventsStore);\n\nexport const delTrackEvents = (keys: IDBValidKey[]): Promise<void> => delMany(keys, eventsStore);\n"],
|
|
5
|
+
"mappings": "AAAA,SAASA,EAAiBC,EAAS,CAC/B,OAAO,IAAI,QAAQ,CAACC,EAASC,IAAW,CAEpCF,EAAQ,WAAaA,EAAQ,UAAY,IAAMC,EAAQD,EAAQ,MAAM,EAErEA,EAAQ,QAAUA,EAAQ,QAAU,IAAME,EAAOF,EAAQ,KAAK,CAClE,CAAC,CACL,CACA,SAASG,EAAYC,EAAQC,EAAW,CACpC,IAAML,EAAU,UAAU,KAAKI,CAAM,EACrCJ,EAAQ,gBAAkB,IAAMA,EAAQ,OAAO,kBAAkBK,CAAS,EAC1E,IAAMC,EAAMP,EAAiBC,CAAO,EACpC,MAAO,CAACO,EAAQC,IAAaF,EAAI,KAAMG,GAAOD,EAASC,EAAG,YAAYJ,EAAWE,CAAM,EAAE,YAAYF,CAAS,CAAC,CAAC,CACpH,CACA,IAAIK,EACJ,SAASC,GAAkB,CACvB,OAAKD,IACDA,EAAsBP,EAAY,eAAgB,QAAQ,GAEvDO,CACX,CAiBA,SAASE,EAAIC,EAAKC,EAAOC,EAAcC,EAAgB,EAAG,CACtD,OAAOD,EAAY,YAAcE,IAC7BA,EAAM,IAAIH,EAAOD,CAAG,EACbK,EAAiBD,EAAM,WAAW,EAC5C,CACL,CAiEA,SAASE,EAAQC,EAAMC,EAAcC,EAAgB,EAAG,CACpD,OAAOD,EAAY,YAAcE,IAC7BH,EAAK,QAASI,GAAQD,EAAM,OAAOC,CAAG,CAAC,EAChCC,EAAiBF,EAAM,WAAW,EAC5C,CACL,CAYA,SAASG,EAAWC,EAAOC,EAAU,CACjC,OAAAD,EAAM,WAAW,EAAE,UAAY,UAAY,CAClC,KAAK,SAEVC,EAAS,KAAK,MAAM,EACpB,KAAK,OAAO,SAAS,EACzB,EACOC,EAAiBF,EAAM,WAAW,CAC7C,CAoCA,SAASG,EAAQC,EAAcC,EAAgB,EAAG,CAC9C,OAAOD,EAAY,WAAaE,GAAU,CAGtC,GAAIA,EAAM,QAAUA,EAAM,WACtB,OAAO,QAAQ,IAAI,CACfC,EAAiBD,EAAM,WAAW,CAAC,EACnCC,EAAiBD,EAAM,OAAO,CAAC,CACnC,CAAC,EAAE,KAAK,CAAC,CAACE,EAAMC,CAAM,IAAMD,EAAK,IAAI,CAACE,EAAKC,IAAM,CAACD,EAAKD,EAAOE,CAAC,CAAC,CAAC,CAAC,EAEtE,IAAMC,EAAQ,CAAC,EACf,OAAOR,EAAY,WAAaE,GAAUO,EAAWP,EAAQQ,GAAWF,EAAM,KAAK,CAACE,EAAO,IAAKA,EAAO,KAAK,CAAC,CAAC,EAAE,KAAK,IAAMF,CAAK,CAAC,CACrI,CAAC,CACL,CClLA,IAAMG,EAAaC,EAAY,aAAc,OAAO,EAC9CC,EAAcD,EAAY,cAAe,QAAQ,EAE1CE,EAAc,CAAC,CAAC,IAAAC,EAAK,KAAAC,CAAI,IACpCC,EAAIF,EAAKC,EAAML,CAAU,EAEdO,EAAe,IAA6CC,EAAQR,CAAU,EAE9ES,EAAgBC,GAAuCC,EAAQD,EAAMV,CAAU,EAE/EY,EAAgB,CAAC,CAAC,IAAAR,EAAK,MAAAS,CAAK,IACvCP,EAAIF,EAAKS,EAAOX,CAAW,EAEhBY,EAAiB,IAA+CN,EAAQN,CAAW,EAEnFa,EAAkBL,GAAuCC,EAAQD,EAAMR,CAAW",
|
|
6
|
+
"names": ["promisifyRequest", "request", "resolve", "reject", "createStore", "dbName", "storeName", "dbp", "txMode", "callback", "db", "defaultGetStoreFunc", "defaultGetStore", "set", "key", "value", "customStore", "defaultGetStore", "store", "promisifyRequest", "delMany", "keys", "customStore", "defaultGetStore", "store", "key", "promisifyRequest", "eachCursor", "store", "callback", "promisifyRequest", "entries", "customStore", "defaultGetStore", "store", "promisifyRequest", "keys", "values", "key", "i", "items", "eachCursor", "cursor", "viewsStore", "createStore", "eventsStore", "setPageView", "key", "view", "set", "getPageViews", "entries", "delPageViews", "keys", "delMany", "setTrackEvent", "track", "getTrackEvents", "delTrackEvents"]
|
|
7
7
|
}
|
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var y=e=>e==null,u=e=>!y(e),b=class extends Error{},o=(e,t)=>{if(y(e))throw new b(t)},i=e=>u(e)?[e]:[];var m=()=>typeof window<"u";var l=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,
|
|
1
|
+
var y=e=>e==null,u=e=>!y(e),b=class extends Error{},o=(e,t)=>{if(y(e))throw new b(t)},i=e=>u(e)?[e]:[];var m=()=>typeof window<"u";var l=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");var f=()=>BigInt(Date.now())*BigInt(1e6);var d=()=>({collected_at:f(),updated_at:[]}),g=()=>{let{userAgent:e}=navigator;return{user_agent:i(e)}};var S=()=>{if(!(typeof crypto>"u"))return l()},p=S(),r,k=e=>{let{path:t}=e.worker??{},n=t===void 0?"./workers/analytics.worker.js":t;r=new Worker(n);let s=()=>console.warn("Unable to connect to the analytics web worker. Have you deployed it?");return r?.addEventListener("error",s,!1),P(e),{cleanup(){r?.removeEventListener("error",s,!1)}}},v=()=>{let e=async()=>await E(),t=new Proxy(history.pushState,{apply:async(n,s,c)=>{n.apply(s,c),await e()}});return history.pushState=t,addEventListener("popstate",e,{passive:!0}),{cleanup(){t=null,removeEventListener("popstate",e,!1)}}},a="Analytics worker not initialized. Did you call `initOrbiter`?",h="No session ID initialized.",w=async()=>{if(!m())return;o(p,h);let{title:e,location:{href:t},referrer:n}=document,{innerWidth:s,innerHeight:c}=window,{timeZone:I}=Intl.DateTimeFormat().resolvedOptions(),T={title:e,href:t,referrer:i(u(n)&&n!==""?n:void 0),device:{inner_width:s,inner_height:c},time_zone:I,session_id:p,...g(),...d()};await(await import("./idb.services-V6IDWAXJ.js")).setPageView({key:l(),view:T})},E=async()=>{o(r,a),await w(),r?.postMessage({msg:"junoTrackPageView"})},_=async e=>{if(!m())return;o(p,h),o(r,a),await(await import("./idb.services-V6IDWAXJ.js")).setTrackEvent({key:l(),track:{...e,session_id:p,...g(),...d()}}),r?.postMessage({msg:"junoTrackEvent"})},P=e=>{o(r,a),r?.postMessage({msg:"junoInitEnvironment",data:e})},x=()=>{o(r,a),r?.postMessage({msg:"junoStartTrackTimer"})},N=()=>{o(r,a),r?.postMessage({msg:"junoStopTracker"})};var H=async e=>{await w();let{cleanup:t}=k(e),{cleanup:n}=v();return x(),()=>{N(),t(),n()}};export{H as initOrbiter,_ as trackEvent,E as trackPageView};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../utils/src/utils/debounce.utils.ts", "../../../utils/src/utils/null.utils.ts", "../../../utils/src/utils/did.utils.ts", "../../../utils/src/utils/env.utils.ts", "../../../../node_modules/nanoid/index.browser.js", "../../src/utils/date.utils.ts", "../../src/utils/analytics.utils.ts", "../../src/services/analytics.services.ts", "../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable-next-line @typescript-eslint/ban-types */\nexport const debounce = (func: Function, timeout?: number) => {\n let timer: NodeJS.Timer | undefined;\n\n return (...args: unknown[]) => {\n const next = () => func(...args);\n\n if (timer) {\n clearTimeout(timer);\n }\n\n timer = setTimeout(next, timeout !== undefined && timeout > 0 ? timeout : 300);\n };\n};\n", "/** Is null or undefined */\nexport const isNullish = <T>(argument: T | undefined | null): argument is undefined | null =>\n argument === null || argument === undefined;\n\n/** Not null and not undefined */\nexport const nonNullish = <T>(argument: T | undefined | null): argument is NonNullable<T> =>\n !isNullish(argument);\n\nexport class NullishError extends Error {}\n\nexport const assertNonNullish: <T>(\n value: T,\n message?: string\n) => asserts value is NonNullable<T> = <T>(value: T, message?: string): void => {\n if (isNullish(value)) {\n throw new NullishError(message);\n }\n};\n", "import {nonNullish} from './null.utils';\n\nexport const toNullable = <T>(value?: T): [] | [T] => {\n return nonNullish(value) ? [value] : [];\n};\n\nexport const fromNullable = <T>(value: [] | [T]): T | undefined => {\n return value?.[0];\n};\n\nexport const toArray = async <T>(data: T): Promise<Uint8Array> => {\n const blob: Blob = new Blob([JSON.stringify(data)], {\n type: 'application/json; charset=utf-8'\n });\n return new Uint8Array(await blob.arrayBuffer());\n};\n\nexport const fromArray = async <T>(data: Uint8Array | number[]): Promise<T> => {\n const blob: Blob = new Blob([data instanceof Uint8Array ? data : new Uint8Array(data)], {\n type: 'application/json; charset=utf-8'\n });\n return JSON.parse(await blob.text());\n};\n", "export const isBrowser = () => typeof window !== `undefined`;\n", "export { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nexport let nanoid = (size = 21) =>\n crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {\n byte &= 63\n if (byte < 36) {\n id += byte.toString(36)\n } else if (byte < 62) {\n id += (byte - 26).toString(36).toUpperCase()\n } else if (byte > 62) {\n id += '-'\n } else {\n id += '_'\n }\n return id\n }, '')\n", "export const nowInBigIntNanoSeconds = (): bigint => BigInt(Date.now()) * BigInt(1e6);\n", "import {toNullable} from '@junobuild/utils';\nimport {nowInBigIntNanoSeconds} from './date.utils';\n\nexport const timestamp = (): {collected_at: bigint; updated_at: [] | [bigint]} => ({\n collected_at: nowInBigIntNanoSeconds(),\n updated_at: []\n});\n\nexport const userAgent = (): {user_agent: [] | [string]} => {\n const {userAgent} = navigator;\n return {user_agent: toNullable(userAgent)};\n};\n", "import {assertNonNullish, isBrowser, nonNullish, toNullable} from '@junobuild/utils';\nimport {nanoid} from 'nanoid';\nimport type {Environment, EnvironmentWorker} from '../types/env';\nimport type {IdbPageView} from '../types/idb';\nimport type {PostMessageInitEnvData} from '../types/post-message';\nimport type {TrackEvent} from '../types/track';\nimport {timestamp, userAgent} from '../utils/analytics.utils';\n\nconst initSessionId = (): string | undefined => {\n // I faced this issue when I used the library in Docusaurus which does not implement the crypto API when server-side rendering.\n // https://github.com/ai/nanoid/issues?q=crypto+not+defined\n if (typeof crypto === 'undefined') {\n return undefined;\n }\n\n return nanoid();\n}
|
|
5
|
-
"mappings": "ACCO,IAAMA,EAAgBC,GAC3BA,GAAa,KAGFC,EAAiBD,GAC5B,CAACD,EAAUC,CAAQ,EAERE,EAAN,cAA2B,KAAM,CAAC,EAE5BC,EAG0B,CAAIC,EAAUC,IAA2B,CAC9E,GAAIN,EAAUK,CAAK,EACjB,MAAM,IAAIF,EAAaG,CAAO,CAElC,ECfaC,EAAiBF,GACrBH,EAAWG,CAAK,EAAI,CAACA,CAAK,EAAI,CAAC,ECHjC,IAAMG,EAAY,IAAM,OAAO,OAAW,ICmB1C,IAAIC,EAAS,CAACC,EAAO,KAC1B,OAAO,gBAAgB,IAAI,WAAWA,CAAI,CAAC,EAAE,OAAO,CAACC,EAAIC,KACvDA,GAAQ,GACJA,EAAO,GACTD,GAAMC,EAAK,SAAS,EAAE,EACbA,EAAO,GAChBD,IAAOC,EAAO,IAAI,SAAS,EAAE,EAAE,YAAY,EAClCA,EAAO,GAChBD,GAAM,IAENA,GAAM,IAEDA,GACN,EAAE,EChCA,IAAME,EAAyB,IAAc,OAAO,KAAK,IAAI,CAAC,EAAI,OAAO,GAAG,ECG5E,IAAMC,EAAY,KAA0D,CACjF,aAAcC,EAAuB,EACrC,WAAY,CAAC,CACf,GAEaC,EAAY,IAAmC,CAC1D,GAAM,CAAC,UAAAA,CAAS,EAAI,UACpB,MAAO,CAAC,WAAYC,EAAWD,CAAS,CAAC,CAC3C,ECHA,IAAME,EAAgB,IAA0B,CAG9C,GAAI,SAAO,OAAW,KAItB,OAAOC,EAAO,CAChB,EAEMC,EAAYF,EAAc,EAE5BG,EAESC,EAAcC,GAA4C,CACrE,GAAM,CAAC,KAAAC,CAAI,EAAuBD,EAAI,QAAU,CAAC,EAC3CE,EAAYD,IAAS,OAAY,gCAAkCA,EAEzEH,EAAS,IAAI,OAAOI,CAAS,EAE7B,IAAMC,EAAc,IAClB,QAAQ,KAAK,sEAAsE,EAErF,OAAAL,GAAQ,iBAAiB,QAASK,EAAa,EAAK,EAEpDC,EAAsBJ,CAAG,EAElB,CACL,SAAU,CACRF,GAAQ,oBAAoB,QAASK,EAAa,EAAK,CACzD,CACF,CACF,EAEaE,EAAqB,IAA6B,CAC7D,IAAMC,EAAa,SAAY,MAAMC,EAAc,EAE/CC,EAAkD,IAAI,MAAM,QAAQ,UAAW,CACjF,MAAO,MACLC,EACAC,EACAC,IACG,CACHF,EAAO,MAAMC,EAASC,CAAQ,EAC9B,MAAML,EAAW,CACnB,CACF,CAAC,EAED,eAAQ,UAAYE,EAEpB,iBAAiB,WAAYF,EAAY,CAAC,QAAS,EAAI,CAAC,EAEjD,CACL,SAAU,CACRE,EAAiB,KACjB,oBAAoB,WAAYF,EAAY,EAAK,CACnD,CACF,CACF,EAEMM,EACJ,gEACIC,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable-next-line @typescript-eslint/ban-types */\nexport const debounce = (func: Function, timeout?: number) => {\n let timer: NodeJS.Timer | undefined;\n\n return (...args: unknown[]) => {\n const next = () => func(...args);\n\n if (timer) {\n clearTimeout(timer);\n }\n\n timer = setTimeout(next, timeout !== undefined && timeout > 0 ? timeout : 300);\n };\n};\n", "/** Is null or undefined */\nexport const isNullish = <T>(argument: T | undefined | null): argument is undefined | null =>\n argument === null || argument === undefined;\n\n/** Not null and not undefined */\nexport const nonNullish = <T>(argument: T | undefined | null): argument is NonNullable<T> =>\n !isNullish(argument);\n\nexport class NullishError extends Error {}\n\nexport const assertNonNullish: <T>(\n value: T,\n message?: string\n) => asserts value is NonNullable<T> = <T>(value: T, message?: string): void => {\n if (isNullish(value)) {\n throw new NullishError(message);\n }\n};\n", "import {nonNullish} from './null.utils';\n\nexport const toNullable = <T>(value?: T): [] | [T] => {\n return nonNullish(value) ? [value] : [];\n};\n\nexport const fromNullable = <T>(value: [] | [T]): T | undefined => {\n return value?.[0];\n};\n\nexport const toArray = async <T>(data: T): Promise<Uint8Array> => {\n const blob: Blob = new Blob([JSON.stringify(data)], {\n type: 'application/json; charset=utf-8'\n });\n return new Uint8Array(await blob.arrayBuffer());\n};\n\nexport const fromArray = async <T>(data: Uint8Array | number[]): Promise<T> => {\n const blob: Blob = new Blob([data instanceof Uint8Array ? data : new Uint8Array(data)], {\n type: 'application/json; charset=utf-8'\n });\n return JSON.parse(await blob.text());\n};\n", "export const isBrowser = () => typeof window !== `undefined`;\n", "export { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nexport let nanoid = (size = 21) =>\n crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {\n byte &= 63\n if (byte < 36) {\n id += byte.toString(36)\n } else if (byte < 62) {\n id += (byte - 26).toString(36).toUpperCase()\n } else if (byte > 62) {\n id += '-'\n } else {\n id += '_'\n }\n return id\n }, '')\n", "export const nowInBigIntNanoSeconds = (): bigint => BigInt(Date.now()) * BigInt(1e6);\n", "import {toNullable} from '@junobuild/utils';\nimport {nowInBigIntNanoSeconds} from './date.utils';\n\nexport const timestamp = (): {collected_at: bigint; updated_at: [] | [bigint]} => ({\n collected_at: nowInBigIntNanoSeconds(),\n updated_at: []\n});\n\nexport const userAgent = (): {user_agent: [] | [string]} => {\n const {userAgent} = navigator;\n return {user_agent: toNullable(userAgent)};\n};\n", "import {assertNonNullish, isBrowser, nonNullish, toNullable} from '@junobuild/utils';\nimport {nanoid} from 'nanoid';\nimport type {Environment, EnvironmentWorker} from '../types/env';\nimport type {IdbPageView} from '../types/idb';\nimport type {PostMessageInitEnvData} from '../types/post-message';\nimport type {TrackEvent} from '../types/track';\nimport {timestamp, userAgent} from '../utils/analytics.utils';\n\nconst initSessionId = (): string | undefined => {\n // I faced this issue when I used the library in Docusaurus which does not implement the crypto API when server-side rendering.\n // https://github.com/ai/nanoid/issues?q=crypto+not+defined\n if (typeof crypto === 'undefined') {\n return undefined;\n }\n\n return nanoid();\n};\n\nconst sessionId = initSessionId();\n\nlet worker: Worker | undefined;\n\nexport const initWorker = (env: Environment): {cleanup: () => void} => {\n const {path}: EnvironmentWorker = env.worker ?? {};\n const workerUrl = path === undefined ? './workers/analytics.worker.js' : path;\n\n worker = new Worker(workerUrl);\n\n const consoleWarn = () =>\n console.warn('Unable to connect to the analytics web worker. Have you deployed it?');\n\n worker?.addEventListener('error', consoleWarn, false);\n\n initWorkerEnvironment(env);\n\n return {\n cleanup() {\n worker?.removeEventListener('error', consoleWarn, false);\n }\n };\n};\n\nexport const initTrackPageViews = (): {cleanup: () => void} => {\n const trackPages = async () => await trackPageView();\n\n let pushStateProxy: typeof history.pushState | null = new Proxy(history.pushState, {\n apply: async (\n target,\n thisArg,\n argArray: [data: unknown, unused: string, url?: string | URL | null | undefined]\n ) => {\n target.apply(thisArg, argArray);\n await trackPages();\n }\n });\n\n history.pushState = pushStateProxy;\n\n addEventListener('popstate', trackPages, {passive: true});\n\n return {\n cleanup() {\n pushStateProxy = null;\n removeEventListener('popstate', trackPages, false);\n }\n };\n};\n\nconst WORKER_UNDEFINED_MSG =\n 'Analytics worker not initialized. Did you call `initOrbiter`?' as const;\nconst SESSION_ID_UNDEFINED_MSG = 'No session ID initialized.' as const;\n\nexport const setPageView = async () => {\n if (!isBrowser()) {\n return;\n }\n\n assertNonNullish(sessionId, SESSION_ID_UNDEFINED_MSG);\n\n const {\n title,\n location: {href},\n referrer\n } = document;\n const {innerWidth, innerHeight} = window;\n const {timeZone} = Intl.DateTimeFormat().resolvedOptions();\n\n const data: IdbPageView = {\n title,\n href,\n referrer: toNullable(nonNullish(referrer) && referrer !== '' ? referrer : undefined),\n device: {\n inner_width: innerWidth,\n inner_height: innerHeight\n },\n time_zone: timeZone,\n session_id: sessionId as string,\n ...userAgent(),\n ...timestamp()\n };\n\n const idb = await import('./idb.services');\n await idb.setPageView({\n key: nanoid(),\n view: data\n });\n};\n\nexport const trackPageView = async () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n await setPageView();\n\n worker?.postMessage({msg: 'junoTrackPageView'});\n};\n\nexport const trackEvent = async (data: TrackEvent) => {\n if (!isBrowser()) {\n return;\n }\n\n assertNonNullish(sessionId, SESSION_ID_UNDEFINED_MSG);\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n const idb = await import('./idb.services');\n await idb.setTrackEvent({\n key: nanoid(),\n track: {...data, session_id: sessionId as string, ...userAgent(), ...timestamp()}\n });\n\n worker?.postMessage({msg: 'junoTrackEvent'});\n};\n\nexport const initWorkerEnvironment = (env: PostMessageInitEnvData) => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoInitEnvironment', data: env});\n};\n\nexport const startTracking = () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoStartTrackTimer'});\n};\n\nexport const stopTracking = () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoStopTracker'});\n};\n", "import {\n initTrackPageViews,\n initWorker,\n setPageView,\n startTracking,\n stopTracking\n} from './services/analytics.services';\nimport type {Environment} from './types/env';\n\nexport {trackEvent, trackPageView} from './services/analytics.services';\nexport * from './types/env';\n\nexport const initOrbiter = async (env: Environment): Promise<() => void> => {\n // Save first page as soon as possible\n await setPageView();\n\n const {cleanup: workerCleanup} = initWorker(env);\n\n const {cleanup: pushHistoryCleanup} = initTrackPageViews();\n\n // Starting tracking will instantly sync the first page and the data from previous sessions that have not been synced yet\n startTracking();\n\n return () => {\n stopTracking();\n workerCleanup();\n pushHistoryCleanup();\n };\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["isNullish", "argument", "nonNullish", "NullishError", "assertNonNullish", "value", "message", "toNullable", "isBrowser", "nanoid", "size", "id", "byte", "nowInBigIntNanoSeconds", "timestamp", "nowInBigIntNanoSeconds", "userAgent", "T", "initSessionId", "nanoid", "sessionId", "worker", "initWorker", "env", "path", "workerUrl", "consoleWarn", "initWorkerEnvironment", "initTrackPageViews", "trackPages", "trackPageView", "pushStateProxy", "target", "thisArg", "argArray", "WORKER_UNDEFINED_MSG", "SESSION_ID_UNDEFINED_MSG", "setPageView", "y", "f", "title", "href", "referrer", "innerWidth", "innerHeight", "timeZone", "data", "T", "s", "userAgent", "timestamp", "trackEvent", "startTracking", "stopTracking", "initOrbiter", "env", "setPageView", "workerCleanup", "initWorker", "pushHistoryCleanup", "initTrackPageViews", "startTracking", "stopTracking"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type {ActorConfig, ActorSubclass, Agent, HttpAgentOptions} from '@dfinity/agent';
|
|
2
|
+
import type {IDL} from '@dfinity/candid';
|
|
3
|
+
import type {Principal} from '@dfinity/principal';
|
|
4
|
+
|
|
5
|
+
import {_SERVICE} from './index.did';
|
|
6
|
+
|
|
7
|
+
export declare const idlFactory: IDL.InterfaceFactory;
|
|
8
|
+
export declare const canisterId: string;
|
|
9
|
+
|
|
10
|
+
export declare interface CreateActorOptions {
|
|
11
|
+
/**
|
|
12
|
+
* @see {@link Agent}
|
|
13
|
+
*/
|
|
14
|
+
agent?: Agent;
|
|
15
|
+
/**
|
|
16
|
+
* @see {@link HttpAgentOptions}
|
|
17
|
+
*/
|
|
18
|
+
agentOptions?: HttpAgentOptions;
|
|
19
|
+
/**
|
|
20
|
+
* @see {@link ActorConfig}
|
|
21
|
+
*/
|
|
22
|
+
actorOptions?: ActorConfig;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister.
|
|
27
|
+
* @constructs {@link ActorSubClass}
|
|
28
|
+
* @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to
|
|
29
|
+
* @param {CreateActorOptions} options - see {@link CreateActorOptions}
|
|
30
|
+
* @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions
|
|
31
|
+
* @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent
|
|
32
|
+
* @see {@link HttpAgentOptions}
|
|
33
|
+
* @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor
|
|
34
|
+
* @see {@link ActorConfig}
|
|
35
|
+
*/
|
|
36
|
+
export declare const createActor: (
|
|
37
|
+
canisterId: string | Principal,
|
|
38
|
+
options?: CreateActorOptions
|
|
39
|
+
) => ActorSubclass<_SERVICE>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Intialized Actor using default settings, ready to talk to a canister using its candid interface
|
|
43
|
+
* @constructs {@link ActorSubClass}
|
|
44
|
+
*/
|
|
45
|
+
export declare const index: ActorSubclass<_SERVICE>;
|