@jsm-mit/rabbit-motoko-package 0.1.3 → 0.1.4
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/rabbit-motoko-actor.d.ts +1 -1
- package/dist/rabbit-motoko-actor.d.ts.map +1 -1
- package/dist/rabbit-motoko-actor.js +1 -1
- package/package.json +1 -1
- package/declarations/rabbit-motoko-backend/index.d.ts +0 -50
- package/declarations/rabbit-motoko-backend/index.js +0 -42
- package/declarations/rabbit-motoko-backend/rabbit-motoko-backend.did +0 -39
- package/declarations/rabbit-motoko-backend/rabbit-motoko-backend.did.d.ts +0 -35
- package/declarations/rabbit-motoko-backend/rabbit-motoko-backend.did.js +0 -35
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AddTaskArgs, ClaimTaskArgs, CompleteTaskArgs, Task } from "
|
|
1
|
+
import type { AddTaskArgs, ClaimTaskArgs, CompleteTaskArgs, Task } from "./declarations/service.did.js";
|
|
2
2
|
export declare class RabbitMotokoActor {
|
|
3
3
|
private readonly canisterId;
|
|
4
4
|
private readonly host;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rabbit-motoko-actor.d.ts","sourceRoot":"","sources":["../src/rabbit-motoko-actor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAER,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,IAAI,EACP,MAAM,
|
|
1
|
+
{"version":3,"file":"rabbit-motoko-actor.d.ts","sourceRoot":"","sources":["../src/rabbit-motoko-actor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAER,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,IAAI,EACP,MAAM,+BAA+B,CAAC;AAEvC,qBAAa,iBAAiB;IAKd,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJvC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6B;IAClD,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,KAAK,CAAY;gBAEI,UAAU,EAAE,MAAM;IAe/C,OAAO,CAAC,SAAS;YAOH,UAAU;YAWV,UAAU;IAQX,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IASlC;;OAEG;IACU,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAUxD;;OAEG;IACU,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IAUjE;;OAEG;IACU,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAUnE;;OAEG;IACU,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAUpE;;OAEG;IACU,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;CAS3C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Actor, HttpAgent } from "@dfinity/agent";
|
|
2
|
-
import { idlFactory } from "
|
|
2
|
+
import { idlFactory } from "./declarations/service.did.js";
|
|
3
3
|
export class RabbitMotokoActor {
|
|
4
4
|
constructor(canisterId) {
|
|
5
5
|
this.canisterId = canisterId;
|
package/package.json
CHANGED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ActorSubclass,
|
|
3
|
-
HttpAgentOptions,
|
|
4
|
-
ActorConfig,
|
|
5
|
-
Agent,
|
|
6
|
-
} from "@icp-sdk/core/agent";
|
|
7
|
-
import type { Principal } from "@icp-sdk/core/principal";
|
|
8
|
-
import type { IDL } from "@icp-sdk/core/candid";
|
|
9
|
-
|
|
10
|
-
import { _SERVICE } from './rabbit-motoko-backend.did';
|
|
11
|
-
|
|
12
|
-
export declare const idlFactory: IDL.InterfaceFactory;
|
|
13
|
-
export declare const canisterId: string;
|
|
14
|
-
|
|
15
|
-
export declare interface CreateActorOptions {
|
|
16
|
-
/**
|
|
17
|
-
* @see {@link Agent}
|
|
18
|
-
*/
|
|
19
|
-
agent?: Agent;
|
|
20
|
-
/**
|
|
21
|
-
* @see {@link HttpAgentOptions}
|
|
22
|
-
*/
|
|
23
|
-
agentOptions?: HttpAgentOptions;
|
|
24
|
-
/**
|
|
25
|
-
* @see {@link ActorConfig}
|
|
26
|
-
*/
|
|
27
|
-
actorOptions?: ActorConfig;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister.
|
|
32
|
-
* @constructs {@link ActorSubClass}
|
|
33
|
-
* @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to
|
|
34
|
-
* @param {CreateActorOptions} options - see {@link CreateActorOptions}
|
|
35
|
-
* @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions
|
|
36
|
-
* @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent
|
|
37
|
-
* @see {@link HttpAgentOptions}
|
|
38
|
-
* @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor
|
|
39
|
-
* @see {@link ActorConfig}
|
|
40
|
-
*/
|
|
41
|
-
export declare const createActor: (
|
|
42
|
-
canisterId: string | Principal,
|
|
43
|
-
options?: CreateActorOptions
|
|
44
|
-
) => ActorSubclass<_SERVICE>;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Intialized Actor using default settings, ready to talk to a canister using its candid interface
|
|
48
|
-
* @constructs {@link ActorSubClass}
|
|
49
|
-
*/
|
|
50
|
-
export declare const rabbit_motoko_backend: ActorSubclass<_SERVICE>;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Actor, HttpAgent } from "@icp-sdk/core/agent";
|
|
2
|
-
|
|
3
|
-
// Imports and re-exports candid interface
|
|
4
|
-
import { idlFactory } from "./rabbit-motoko-backend.did.js";
|
|
5
|
-
export { idlFactory } from "./rabbit-motoko-backend.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 =
|
|
13
|
-
process.env.CANISTER_ID_RABBIT_MOTOKO_BACKEND;
|
|
14
|
-
|
|
15
|
-
export const createActor = (canisterId, options = {}) => {
|
|
16
|
-
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
|
|
17
|
-
|
|
18
|
-
if (options.agent && options.agentOptions) {
|
|
19
|
-
console.warn(
|
|
20
|
-
"Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent."
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Fetch root key for certificate validation during development
|
|
25
|
-
if (process.env.DFX_NETWORK !== "ic") {
|
|
26
|
-
agent.fetchRootKey().catch((err) => {
|
|
27
|
-
console.warn(
|
|
28
|
-
"Unable to fetch root key. Check to ensure that your local replica is running"
|
|
29
|
-
);
|
|
30
|
-
console.error(err);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Creates an actor with using the candid interface and the HttpAgent
|
|
35
|
-
return Actor.createActor(idlFactory, {
|
|
36
|
-
agent,
|
|
37
|
-
canisterId,
|
|
38
|
-
...options.actorOptions,
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const rabbit_motoko_backend = canisterId ? createActor(canisterId) : undefined;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
type Task =
|
|
2
|
-
record {
|
|
3
|
-
channel: text;
|
|
4
|
-
completedAt: int;
|
|
5
|
-
createdAt: int;
|
|
6
|
-
expiresAt: int;
|
|
7
|
-
id: nat;
|
|
8
|
-
parentIds: opt vec nat;
|
|
9
|
-
payload: text;
|
|
10
|
-
resultMessage: text;
|
|
11
|
-
status: nat;
|
|
12
|
-
timesOutAt: int;
|
|
13
|
-
worker: principal;
|
|
14
|
-
};
|
|
15
|
-
type CompleteTaskArgs =
|
|
16
|
-
record {
|
|
17
|
-
id: nat;
|
|
18
|
-
message: text;
|
|
19
|
-
};
|
|
20
|
-
type ClaimTaskArgs =
|
|
21
|
-
record {
|
|
22
|
-
id: nat;
|
|
23
|
-
timeoutNanos: int;
|
|
24
|
-
};
|
|
25
|
-
type AddTaskArgs =
|
|
26
|
-
record {
|
|
27
|
-
channel: text;
|
|
28
|
-
parentIds: opt vec nat;
|
|
29
|
-
payload: text;
|
|
30
|
-
};
|
|
31
|
-
service : {
|
|
32
|
-
addTask: (args: AddTaskArgs) -> (nat);
|
|
33
|
-
claimTask: (args: ClaimTaskArgs) -> (opt Task);
|
|
34
|
-
completeTask: (args: CompleteTaskArgs) -> (bool);
|
|
35
|
-
getAvailableTaskIds: (channel: text) -> (vec nat) query;
|
|
36
|
-
getTask: (id: nat) -> (opt Task) query;
|
|
37
|
-
getTasks: () -> (vec Task) query;
|
|
38
|
-
getTasksLast24h: () -> (vec Task) query;
|
|
39
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Principal } from '@icp-sdk/core/principal';
|
|
2
|
-
import type { ActorMethod } from '@icp-sdk/core/agent';
|
|
3
|
-
import type { IDL } from '@icp-sdk/core/candid';
|
|
4
|
-
|
|
5
|
-
export interface AddTaskArgs {
|
|
6
|
-
'parentIds' : [] | [Array<bigint>],
|
|
7
|
-
'channel' : string,
|
|
8
|
-
'payload' : string,
|
|
9
|
-
}
|
|
10
|
-
export interface ClaimTaskArgs { 'id' : bigint, 'timeoutNanos' : bigint }
|
|
11
|
-
export interface CompleteTaskArgs { 'id' : bigint, 'message' : string }
|
|
12
|
-
export interface Task {
|
|
13
|
-
'id' : bigint,
|
|
14
|
-
'status' : bigint,
|
|
15
|
-
'completedAt' : bigint,
|
|
16
|
-
'resultMessage' : string,
|
|
17
|
-
'expiresAt' : bigint,
|
|
18
|
-
'timesOutAt' : bigint,
|
|
19
|
-
'createdAt' : bigint,
|
|
20
|
-
'parentIds' : [] | [Array<bigint>],
|
|
21
|
-
'worker' : Principal,
|
|
22
|
-
'channel' : string,
|
|
23
|
-
'payload' : string,
|
|
24
|
-
}
|
|
25
|
-
export interface _SERVICE {
|
|
26
|
-
'addTask' : ActorMethod<[AddTaskArgs], bigint>,
|
|
27
|
-
'claimTask' : ActorMethod<[ClaimTaskArgs], [] | [Task]>,
|
|
28
|
-
'completeTask' : ActorMethod<[CompleteTaskArgs], boolean>,
|
|
29
|
-
'getAvailableTaskIds' : ActorMethod<[string], Array<bigint>>,
|
|
30
|
-
'getTask' : ActorMethod<[bigint], [] | [Task]>,
|
|
31
|
-
'getTasks' : ActorMethod<[], Array<Task>>,
|
|
32
|
-
'getTasksLast24h' : ActorMethod<[], Array<Task>>,
|
|
33
|
-
}
|
|
34
|
-
export declare const idlFactory: IDL.InterfaceFactory;
|
|
35
|
-
export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export const idlFactory = ({ IDL }) => {
|
|
2
|
-
const AddTaskArgs = IDL.Record({
|
|
3
|
-
'parentIds' : IDL.Opt(IDL.Vec(IDL.Nat)),
|
|
4
|
-
'channel' : IDL.Text,
|
|
5
|
-
'payload' : IDL.Text,
|
|
6
|
-
});
|
|
7
|
-
const ClaimTaskArgs = IDL.Record({
|
|
8
|
-
'id' : IDL.Nat,
|
|
9
|
-
'timeoutNanos' : IDL.Int,
|
|
10
|
-
});
|
|
11
|
-
const Task = IDL.Record({
|
|
12
|
-
'id' : IDL.Nat,
|
|
13
|
-
'status' : IDL.Nat,
|
|
14
|
-
'completedAt' : IDL.Int,
|
|
15
|
-
'resultMessage' : IDL.Text,
|
|
16
|
-
'expiresAt' : IDL.Int,
|
|
17
|
-
'timesOutAt' : IDL.Int,
|
|
18
|
-
'createdAt' : IDL.Int,
|
|
19
|
-
'parentIds' : IDL.Opt(IDL.Vec(IDL.Nat)),
|
|
20
|
-
'worker' : IDL.Principal,
|
|
21
|
-
'channel' : IDL.Text,
|
|
22
|
-
'payload' : IDL.Text,
|
|
23
|
-
});
|
|
24
|
-
const CompleteTaskArgs = IDL.Record({ 'id' : IDL.Nat, 'message' : IDL.Text });
|
|
25
|
-
return IDL.Service({
|
|
26
|
-
'addTask' : IDL.Func([AddTaskArgs], [IDL.Nat], []),
|
|
27
|
-
'claimTask' : IDL.Func([ClaimTaskArgs], [IDL.Opt(Task)], []),
|
|
28
|
-
'completeTask' : IDL.Func([CompleteTaskArgs], [IDL.Bool], []),
|
|
29
|
-
'getAvailableTaskIds' : IDL.Func([IDL.Text], [IDL.Vec(IDL.Nat)], ['query']),
|
|
30
|
-
'getTask' : IDL.Func([IDL.Nat], [IDL.Opt(Task)], ['query']),
|
|
31
|
-
'getTasks' : IDL.Func([], [IDL.Vec(Task)], ['query']),
|
|
32
|
-
'getTasksLast24h' : IDL.Func([], [IDL.Vec(Task)], ['query']),
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
export const init = ({ IDL }) => { return []; };
|