@pax2pay/model-banking 0.1.308 → 0.1.310
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/{Counterbalance2.ts → Counterbalance.ts} +9 -9
- package/Counterbalances.ts +19 -0
- package/Log/Message/Configuration.ts +28 -0
- package/Log/Message/Entry.ts +27 -0
- package/Log/Message/index.ts +27 -0
- package/Log/index.ts +49 -17
- package/Operation/Changes.ts +4 -5
- package/Transaction/index.ts +0 -6
- package/Treasury/Snapshot/Emoney.ts +2 -2
- package/dist/{Counterbalance2.d.ts → Counterbalance.d.ts} +6 -6
- package/dist/{Counterbalance2.js → Counterbalance.js} +11 -11
- package/dist/Counterbalance.js.map +1 -0
- package/dist/{Counterbalances2.d.ts → Counterbalances.d.ts} +4 -4
- package/dist/{Counterbalances2.js → Counterbalances.js} +5 -5
- package/dist/Counterbalances.js.map +1 -0
- package/dist/Log/Message/Configuration.d.ts +13 -0
- package/dist/Log/Message/Configuration.js +21 -0
- package/dist/Log/Message/Configuration.js.map +1 -0
- package/dist/Log/Message/Entry.d.ts +15 -0
- package/dist/Log/Message/Entry.js +22 -0
- package/dist/Log/Message/Entry.js.map +1 -0
- package/dist/Log/Message/index.d.ts +10 -0
- package/dist/Log/Message/index.js +22 -0
- package/dist/Log/Message/index.js.map +1 -0
- package/dist/Log/index.d.ts +17 -6
- package/dist/Log/index.js +43 -18
- package/dist/Log/index.js.map +1 -1
- package/dist/Operation/Changes.d.ts +4 -5
- package/dist/Operation/Changes.js.map +1 -1
- package/dist/Transaction/index.d.ts +0 -6
- package/dist/Transaction/index.js +0 -2
- package/dist/Transaction/index.js.map +1 -1
- package/dist/Treasury/Snapshot/Emoney.d.ts +2 -2
- package/dist/pax2pay.d.ts +2 -3
- package/dist/pax2pay.js +2 -2
- package/dist/pax2pay.js.map +1 -1
- package/package.json +2 -1
- package/pax2pay.ts +2 -3
- package/CounterBalances/Counterbalance.ts +0 -39
- package/CounterBalances/index.ts +0 -31
- package/Counterbalances2.ts +0 -19
- package/Log/Configuration.ts +0 -15
- package/Transaction/Collect/Creatable.ts +0 -14
- package/Transaction/Collect/Failed.ts +0 -33
- package/Transaction/Collect/index.ts +0 -41
- package/dist/CounterBalances/Counterbalance.d.ts +0 -20
- package/dist/CounterBalances/Counterbalance.js +0 -31
- package/dist/CounterBalances/Counterbalance.js.map +0 -1
- package/dist/CounterBalances/index.d.ts +0 -19
- package/dist/CounterBalances/index.js +0 -18
- package/dist/CounterBalances/index.js.map +0 -1
- package/dist/Counterbalance2.js.map +0 -1
- package/dist/Counterbalances2.js.map +0 -1
- package/dist/Log/Configuration.d.ts +0 -10
- package/dist/Log/Configuration.js +0 -11
- package/dist/Log/Configuration.js.map +0 -1
- package/dist/Transaction/Collect/Creatable.d.ts +0 -10
- package/dist/Transaction/Collect/Creatable.js +0 -10
- package/dist/Transaction/Collect/Creatable.js.map +0 -1
- package/dist/Transaction/Collect/Failed.d.ts +0 -17
- package/dist/Transaction/Collect/Failed.js +0 -27
- package/dist/Transaction/Collect/Failed.js.map +0 -1
- package/dist/Transaction/Collect/index.d.ts +0 -20
- package/dist/Transaction/Collect/index.js +0 -38
- package/dist/Transaction/Collect/index.js.map +0 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
3
|
|
|
4
|
-
export type
|
|
5
|
-
minted: Partial<Record<
|
|
6
|
-
burned: Partial<Record<
|
|
4
|
+
export type Counterbalance = {
|
|
5
|
+
minted: Partial<Record<Counterbalance.Source, number>>
|
|
6
|
+
burned: Partial<Record<Counterbalance.Sink, number>>
|
|
7
7
|
}
|
|
8
|
-
export namespace
|
|
8
|
+
export namespace Counterbalance {
|
|
9
9
|
export type Source = string
|
|
10
10
|
export const Source = isly.string()
|
|
11
11
|
export type Sink = string
|
|
12
12
|
export const Sink = isly.string()
|
|
13
|
-
export const type = isly.object<
|
|
14
|
-
minted: isly.record<
|
|
15
|
-
burned: isly.record<
|
|
13
|
+
export const type = isly.object<Counterbalance>({
|
|
14
|
+
minted: isly.record<Counterbalance["minted"]>(Source, isly.number()),
|
|
15
|
+
burned: isly.record<Counterbalance["burned"]>(Sink, isly.number()),
|
|
16
16
|
})
|
|
17
17
|
export type Link = Source | Sink
|
|
18
18
|
export const Link = isly.string()
|
|
19
|
-
export function add(currency: isoly.Currency, addendee:
|
|
20
|
-
const result:
|
|
19
|
+
export function add(currency: isoly.Currency, addendee: Counterbalance, addend: Counterbalance): Counterbalance {
|
|
20
|
+
const result: Counterbalance = { minted: { ...addend.minted }, burned: { ...addend.burned } }
|
|
21
21
|
for (const [source, value] of Object.entries(addendee["minted"]) as [Source, number][]) {
|
|
22
22
|
result["minted"][source] = isoly.Currency.add(currency, value ?? 0, addend["minted"][source] ?? 0)
|
|
23
23
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isoly } from "isoly"
|
|
2
|
+
import { isly } from "isly"
|
|
3
|
+
import { Counterbalance } from "./Counterbalance"
|
|
4
|
+
|
|
5
|
+
export type Counterbalances = Partial<Record<isoly.Currency, Counterbalance>>
|
|
6
|
+
|
|
7
|
+
export namespace Counterbalances {
|
|
8
|
+
export function add(addendee: Counterbalances, addend: Counterbalances): Counterbalances {
|
|
9
|
+
const result: Counterbalances = {}
|
|
10
|
+
for (const [currency, counterbalance] of Object.entries(addendee) as [isoly.Currency, Counterbalance][]) {
|
|
11
|
+
result[currency] = Counterbalance.add(currency, counterbalance, addend[currency] ?? { minted: {}, burned: {} })
|
|
12
|
+
}
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
export const type = isly.record<Counterbalances>(
|
|
16
|
+
isly.fromIs("isoly.Currency", isoly.Currency.is),
|
|
17
|
+
Counterbalance.type
|
|
18
|
+
)
|
|
19
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TraceLog } from "@cloudflare/workers-types"
|
|
2
|
+
import { isly } from "isly"
|
|
3
|
+
import { Realm } from "../../Realm"
|
|
4
|
+
import type { Log } from "../index"
|
|
5
|
+
|
|
6
|
+
export interface Configuration {
|
|
7
|
+
realm: Realm
|
|
8
|
+
collection: string
|
|
9
|
+
resource?: string
|
|
10
|
+
}
|
|
11
|
+
export namespace Configuration {
|
|
12
|
+
export const type = isly.object<Configuration>({
|
|
13
|
+
realm: Realm.type,
|
|
14
|
+
collection: isly.string(),
|
|
15
|
+
resource: isly.string().optional(),
|
|
16
|
+
})
|
|
17
|
+
export function fromTraceLog(
|
|
18
|
+
trace: TraceLog | undefined
|
|
19
|
+
): Pick<Log, "realm" | "collection" | "resource"> | undefined {
|
|
20
|
+
return trace && Configuration.type.is(trace.message[0])
|
|
21
|
+
? {
|
|
22
|
+
realm: trace.message[0].realm,
|
|
23
|
+
collection: trace.message[0].collection,
|
|
24
|
+
resource: trace.message[0].resource,
|
|
25
|
+
}
|
|
26
|
+
: undefined
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TraceLog } from "@cloudflare/workers-types"
|
|
2
|
+
import { isly } from "isly"
|
|
3
|
+
import type { Log } from "../index"
|
|
4
|
+
|
|
5
|
+
export interface Entry {
|
|
6
|
+
message: string
|
|
7
|
+
resource?: string
|
|
8
|
+
data?: any
|
|
9
|
+
}
|
|
10
|
+
export namespace Entry {
|
|
11
|
+
export const type = isly.object<Entry>({
|
|
12
|
+
message: isly.string(),
|
|
13
|
+
resource: isly.string().optional(),
|
|
14
|
+
data: isly.any().optional(),
|
|
15
|
+
})
|
|
16
|
+
export function fromEventLogs(trace: TraceLog): { entry: Log.Entry; resource: Log["resource"] } | undefined {
|
|
17
|
+
return Entry.type.is(trace.message[0])
|
|
18
|
+
? {
|
|
19
|
+
entry: {
|
|
20
|
+
message: trace.message[0].message,
|
|
21
|
+
data: trace.message[0].data,
|
|
22
|
+
},
|
|
23
|
+
resource: trace.message[0].resource,
|
|
24
|
+
}
|
|
25
|
+
: undefined
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TraceLog } from "@cloudflare/workers-types"
|
|
2
|
+
import type { Log } from "../index"
|
|
3
|
+
import { Configuration as MessageConfiguration } from "./Configuration"
|
|
4
|
+
import { Entry as MessageEntry } from "./Entry"
|
|
5
|
+
|
|
6
|
+
export type Message = MessageConfiguration | MessageEntry
|
|
7
|
+
export namespace Message {
|
|
8
|
+
export import Configuration = MessageConfiguration
|
|
9
|
+
export import Entry = MessageEntry
|
|
10
|
+
export function fromEventLogs(
|
|
11
|
+
traces: TraceLog[]
|
|
12
|
+
): Pick<Log, "realm" | "collection" | "resource" | "entries"> | undefined {
|
|
13
|
+
const configuration: Pick<Log, "realm" | "collection" | "resource"> | undefined =
|
|
14
|
+
Message.Configuration.fromTraceLog(traces.find(trace => Message.Configuration.type.is(trace.message[0])))
|
|
15
|
+
const result: Pick<Log, "realm" | "collection" | "resource" | "entries"> | undefined = configuration
|
|
16
|
+
? { ...configuration, entries: [] }
|
|
17
|
+
: undefined
|
|
18
|
+
if (result)
|
|
19
|
+
for (const trace of traces) {
|
|
20
|
+
const logFragment: { entry: Log.Entry; resource: Log["resource"] } | undefined =
|
|
21
|
+
Message.Entry.fromEventLogs(trace)
|
|
22
|
+
logFragment?.resource && (result.resource ??= logFragment.resource)
|
|
23
|
+
logFragment?.entry && result.entries.push(logFragment.entry)
|
|
24
|
+
}
|
|
25
|
+
return result
|
|
26
|
+
}
|
|
27
|
+
}
|
package/Log/index.ts
CHANGED
|
@@ -1,34 +1,66 @@
|
|
|
1
|
+
import { isoly } from "isoly"
|
|
2
|
+
import { TraceItem } from "@cloudflare/workers-types"
|
|
3
|
+
import { isly } from "isly"
|
|
1
4
|
import { Identifier } from "../Identifier"
|
|
2
|
-
import {
|
|
3
|
-
import { Entry } from "./Entry"
|
|
5
|
+
import { Realm } from "../Realm"
|
|
6
|
+
import { Entry as LogEntry } from "./Entry"
|
|
7
|
+
import { Message as LogMessage } from "./Message"
|
|
4
8
|
|
|
5
|
-
export interface Log
|
|
9
|
+
export interface Log {
|
|
6
10
|
id: Identifier
|
|
7
|
-
|
|
11
|
+
realm: Realm
|
|
12
|
+
script?: string
|
|
13
|
+
collection: string
|
|
14
|
+
resource?: string
|
|
15
|
+
entries: Log.Entry[]
|
|
16
|
+
created: isoly.DateTime
|
|
8
17
|
}
|
|
9
18
|
export namespace Log {
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
export import Message = LogMessage
|
|
20
|
+
export import Entry = LogEntry
|
|
21
|
+
export const type = isly.object<Log>({
|
|
22
|
+
id: Identifier.type,
|
|
23
|
+
realm: Realm.type,
|
|
24
|
+
script: isly.string(),
|
|
25
|
+
collection: isly.string(),
|
|
26
|
+
resource: isly.string().optional(),
|
|
27
|
+
entries: Log.Entry.type.array(),
|
|
28
|
+
created: isly.fromIs("isoly.DateTime", isoly.DateTime.is),
|
|
29
|
+
})
|
|
30
|
+
export function fromEvents(events: TraceItem[]): Log[] {
|
|
31
|
+
const result: Log[] = []
|
|
32
|
+
for (const event of events) {
|
|
33
|
+
const created = event.eventTimestamp
|
|
34
|
+
? isoly.DateTime.create(event.eventTimestamp, "milliseconds")
|
|
35
|
+
: isoly.DateTime.now()
|
|
36
|
+
const message = Log.Message.fromEventLogs(event.logs)
|
|
37
|
+
if (message) {
|
|
38
|
+
const log: Log = {
|
|
39
|
+
id: Identifier.generate(),
|
|
40
|
+
realm: message.realm,
|
|
41
|
+
collection: message.collection,
|
|
42
|
+
entries: message.entries,
|
|
43
|
+
created,
|
|
44
|
+
}
|
|
45
|
+
message.resource && (log.resource = message.resource)
|
|
46
|
+
event.scriptName && (log.script = event.scriptName)
|
|
47
|
+
result.push(log)
|
|
48
|
+
}
|
|
18
49
|
}
|
|
50
|
+
return result
|
|
19
51
|
}
|
|
20
52
|
export function configure(collection: string, realm: string | undefined, resource?: string): void {
|
|
21
53
|
const configuration = { collection, realm, resource }
|
|
22
|
-
if (Configuration.type.is(configuration))
|
|
23
|
-
console.log(
|
|
54
|
+
if (Log.Message.Configuration.type.is(configuration))
|
|
55
|
+
console.log(configuration)
|
|
24
56
|
}
|
|
25
57
|
export function log(message: string, data?: any, resource?: string): void {
|
|
26
|
-
console.log(
|
|
58
|
+
console.log(Log.Entry.Message.to(message, data, resource))
|
|
27
59
|
}
|
|
28
60
|
export function warning(message: string, data?: any, resource?: string): void {
|
|
29
|
-
console.warn(
|
|
61
|
+
console.warn(Log.Entry.Message.to(message, data, resource))
|
|
30
62
|
}
|
|
31
63
|
export function exception(message: string, data?: any, resource?: string): void {
|
|
32
|
-
console.error(
|
|
64
|
+
console.error(Log.Entry.Message.to(message, data, resource))
|
|
33
65
|
}
|
|
34
66
|
}
|
package/Operation/Changes.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
3
|
import { Balances } from "../Balances"
|
|
4
|
-
import {
|
|
5
|
-
import { Counterbalances } from "../CounterBalances"
|
|
4
|
+
import { Counterbalance as CounterbalanceOperation } from "../Counterbalance"
|
|
6
5
|
import { Change } from "./Change"
|
|
7
6
|
|
|
8
7
|
export type Changes = Partial<Record<Balances.Balance.Entry, Change>> & Record<Changes.Entry.Counterbalance, Change>
|
|
9
8
|
|
|
10
9
|
export namespace Changes {
|
|
11
10
|
export namespace Entry {
|
|
12
|
-
export type Counterbalance = `${
|
|
13
|
-
export function split(counterbalance: Counterbalance): [
|
|
11
|
+
export type Counterbalance = `${CounterbalanceOperation.Link}-${isoly.DateTime}`
|
|
12
|
+
export function split(counterbalance: Counterbalance): [CounterbalanceOperation.Link, isoly.DateTime] {
|
|
14
13
|
const split = counterbalance.split("-")
|
|
15
14
|
const [realm, supplier, account, hour] = [split[0], split[1], split[2], split.slice(3).join("-")]
|
|
16
15
|
return [`${realm}-${supplier}-${account}`, hour]
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
|
-
export type Entry = Balances.Balance.Entry | Entry.Counterbalance
|
|
18
|
+
export type Entry = Balances.Balance.Entry | Entry.Counterbalance
|
|
20
19
|
export const type = isly.record<Changes>(isly.string(), Change.type)
|
|
21
20
|
export const is = type.is
|
|
22
21
|
export const flaw = type.flaw
|
package/Transaction/index.ts
CHANGED
|
@@ -6,7 +6,6 @@ import { Operation } from "../Operation"
|
|
|
6
6
|
import { Rail } from "../Rail"
|
|
7
7
|
import { Report } from "../Report"
|
|
8
8
|
import type { Rule } from "../Rule"
|
|
9
|
-
import { Collect as TransactionCollect } from "./Collect"
|
|
10
9
|
import { Creatable as TransactionCreatable } from "./Creatable"
|
|
11
10
|
import { Incoming as TransactionIncoming } from "./Incoming"
|
|
12
11
|
import { Note as TransactionNote } from "./Note"
|
|
@@ -49,11 +48,6 @@ export namespace Transaction {
|
|
|
49
48
|
export const directions = ["inbound", "outbound"] as const
|
|
50
49
|
export type Direction = typeof directions[number]
|
|
51
50
|
export import Creatable = TransactionCreatable
|
|
52
|
-
export type Collect = TransactionCollect
|
|
53
|
-
export const Collect = TransactionCollect
|
|
54
|
-
export namespace Collect {
|
|
55
|
-
export type Creatable = TransactionCollect.Creatable
|
|
56
|
-
}
|
|
57
51
|
export import Incoming = TransactionIncoming
|
|
58
52
|
export import Reference = TransactionReference
|
|
59
53
|
export import Note = TransactionNote
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { Balances } from "../../Balances"
|
|
3
|
-
import {
|
|
3
|
+
import { Counterbalances } from "../../Counterbalances"
|
|
4
4
|
|
|
5
5
|
export interface Emoney {
|
|
6
6
|
organization: string
|
|
7
7
|
account: string
|
|
8
8
|
timestamp: isoly.DateTime
|
|
9
9
|
balances: Balances
|
|
10
|
-
counterbalances:
|
|
10
|
+
counterbalances: Counterbalances
|
|
11
11
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
2
|
import { isly } from "isly";
|
|
3
|
-
export type
|
|
4
|
-
minted: Partial<Record<
|
|
5
|
-
burned: Partial<Record<
|
|
3
|
+
export type Counterbalance = {
|
|
4
|
+
minted: Partial<Record<Counterbalance.Source, number>>;
|
|
5
|
+
burned: Partial<Record<Counterbalance.Sink, number>>;
|
|
6
6
|
};
|
|
7
|
-
export declare namespace
|
|
7
|
+
export declare namespace Counterbalance {
|
|
8
8
|
type Source = string;
|
|
9
9
|
const Source: isly.Type<string>;
|
|
10
10
|
type Sink = string;
|
|
11
11
|
const Sink: isly.Type<string>;
|
|
12
|
-
const type: isly.object.ExtendableType<
|
|
12
|
+
const type: isly.object.ExtendableType<Counterbalance>;
|
|
13
13
|
type Link = Source | Sink;
|
|
14
14
|
const Link: isly.Type<string>;
|
|
15
|
-
function add(currency: isoly.Currency, addendee:
|
|
15
|
+
function add(currency: isoly.Currency, addendee: Counterbalance, addend: Counterbalance): Counterbalance;
|
|
16
16
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
2
|
import { isly } from "isly";
|
|
3
|
-
export var
|
|
4
|
-
(function (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
minted: isly.record(
|
|
9
|
-
burned: isly.record(
|
|
3
|
+
export var Counterbalance;
|
|
4
|
+
(function (Counterbalance) {
|
|
5
|
+
Counterbalance.Source = isly.string();
|
|
6
|
+
Counterbalance.Sink = isly.string();
|
|
7
|
+
Counterbalance.type = isly.object({
|
|
8
|
+
minted: isly.record(Counterbalance.Source, isly.number()),
|
|
9
|
+
burned: isly.record(Counterbalance.Sink, isly.number()),
|
|
10
10
|
});
|
|
11
|
-
|
|
11
|
+
Counterbalance.Link = isly.string();
|
|
12
12
|
function add(currency, addendee, addend) {
|
|
13
13
|
const result = { minted: { ...addend.minted }, burned: { ...addend.burned } };
|
|
14
14
|
for (const [source, value] of Object.entries(addendee["minted"])) {
|
|
@@ -19,6 +19,6 @@ export var Counterbalance2;
|
|
|
19
19
|
}
|
|
20
20
|
return result;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
})(
|
|
24
|
-
//# sourceMappingURL=
|
|
22
|
+
Counterbalance.add = add;
|
|
23
|
+
})(Counterbalance || (Counterbalance = {}));
|
|
24
|
+
//# sourceMappingURL=Counterbalance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Counterbalance.js","sourceRoot":"../","sources":["Counterbalance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAM3B,MAAM,KAAW,cAAc,CAqB9B;AArBD,WAAiB,cAAc;IAEjB,qBAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;IAEtB,mBAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;IACpB,mBAAI,GAAG,IAAI,CAAC,MAAM,CAAiB;QAC/C,MAAM,EAAE,IAAI,CAAC,MAAM,CAA2B,eAAA,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QACpE,MAAM,EAAE,IAAI,CAAC,MAAM,CAA2B,eAAA,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;KAClE,CAAC,CAAA;IAEW,mBAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;IACjC,SAAgB,GAAG,CAAC,QAAwB,EAAE,QAAwB,EAAE,MAAsB;QAC7F,MAAM,MAAM,GAAmB,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,CAAA;QAC7F,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAuB,EAAE,CAAC;YACxF,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;QACnG,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAqB,EAAE,CAAC;YACpF,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QAC/F,CAAC;QACD,OAAO,MAAM,CAAA;IACd,CAAC;IATe,kBAAG,MASlB,CAAA;AACF,CAAC,EArBgB,cAAc,KAAd,cAAc,QAqB9B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
2
|
import { isly } from "isly";
|
|
3
|
-
import {
|
|
4
|
-
export type
|
|
3
|
+
import { Counterbalance } from "./Counterbalance";
|
|
4
|
+
export type Counterbalances = Partial<Record<isoly.Currency, Counterbalance>>;
|
|
5
5
|
export declare namespace Counterbalances {
|
|
6
|
-
function add(addendee:
|
|
7
|
-
const type: isly.Type<Partial<Record<"BTN" | "CHE" | "MKD" | "AED" | "AFN" | "ALL" | "AMD" | "ANG" | "AOA" | "ARS" | "AUD" | "AWG" | "AZN" | "BAM" | "BBD" | "BDT" | "BGN" | "BHD" | "BIF" | "BMD" | "BND" | "BOB" | "BOV" | "BRL" | "BSD" | "BWP" | "BYN" | "BZD" | "CAD" | "CDF" | "CHF" | "CHW" | "CLF" | "CLP" | "CNY" | "COP" | "COU" | "CRC" | "CUC" | "CUP" | "CVE" | "CZK" | "DJF" | "DKK" | "DOP" | "DZD" | "EGP" | "ERN" | "ETB" | "EUR" | "FJD" | "FKP" | "GBP" | "GEL" | "GHS" | "GIP" | "GMD" | "GNF" | "GTQ" | "GYD" | "HKD" | "HNL" | "HRK" | "HTG" | "HUF" | "IDR" | "ILS" | "INR" | "IQD" | "IRR" | "ISK" | "JMD" | "JOD" | "JPY" | "KES" | "KGS" | "KHR" | "KMF" | "KPW" | "KRW" | "KWD" | "KYD" | "KZT" | "LAK" | "LBP" | "LKR" | "LRD" | "LSL" | "LYD" | "MAD" | "MDL" | "MGA" | "MMK" | "MNT" | "MOP" | "MRU" | "MUR" | "MVR" | "MWK" | "MXN" | "MXV" | "MYR" | "MZN" | "NAD" | "NGN" | "NIO" | "NOK" | "NPR" | "NZD" | "OMR" | "PAB" | "PEN" | "PGK" | "PHP" | "PKR" | "PLN" | "PYG" | "QAR" | "RON" | "RSD" | "RUB" | "RWF" | "SAR" | "SBD" | "SCR" | "SDG" | "SEK" | "SGD" | "SHP" | "SLL" | "SOS" | "SRD" | "SSP" | "STN" | "SVC" | "SYP" | "SZL" | "THB" | "TJS" | "TMT" | "TND" | "TOP" | "TRY" | "TTD" | "TWD" | "TZS" | "UAH" | "UGX" | "USD" | "USN" | "UYI" | "UYU" | "UYW" | "UZS" | "VES" | "VND" | "VUV" | "WST" | "XAF" | "XAG" | "XAU" | "XBA" | "XBB" | "XBC" | "XBD" | "XCD" | "XDR" | "XOF" | "XPD" | "XPF" | "XPT" | "XSU" | "XTS" | "XUA" | "XXX" | "YER" | "ZAR" | "ZMW" | "ZWL",
|
|
6
|
+
function add(addendee: Counterbalances, addend: Counterbalances): Counterbalances;
|
|
7
|
+
const type: isly.Type<Partial<Record<"BTN" | "CHE" | "MKD" | "AED" | "AFN" | "ALL" | "AMD" | "ANG" | "AOA" | "ARS" | "AUD" | "AWG" | "AZN" | "BAM" | "BBD" | "BDT" | "BGN" | "BHD" | "BIF" | "BMD" | "BND" | "BOB" | "BOV" | "BRL" | "BSD" | "BWP" | "BYN" | "BZD" | "CAD" | "CDF" | "CHF" | "CHW" | "CLF" | "CLP" | "CNY" | "COP" | "COU" | "CRC" | "CUC" | "CUP" | "CVE" | "CZK" | "DJF" | "DKK" | "DOP" | "DZD" | "EGP" | "ERN" | "ETB" | "EUR" | "FJD" | "FKP" | "GBP" | "GEL" | "GHS" | "GIP" | "GMD" | "GNF" | "GTQ" | "GYD" | "HKD" | "HNL" | "HRK" | "HTG" | "HUF" | "IDR" | "ILS" | "INR" | "IQD" | "IRR" | "ISK" | "JMD" | "JOD" | "JPY" | "KES" | "KGS" | "KHR" | "KMF" | "KPW" | "KRW" | "KWD" | "KYD" | "KZT" | "LAK" | "LBP" | "LKR" | "LRD" | "LSL" | "LYD" | "MAD" | "MDL" | "MGA" | "MMK" | "MNT" | "MOP" | "MRU" | "MUR" | "MVR" | "MWK" | "MXN" | "MXV" | "MYR" | "MZN" | "NAD" | "NGN" | "NIO" | "NOK" | "NPR" | "NZD" | "OMR" | "PAB" | "PEN" | "PGK" | "PHP" | "PKR" | "PLN" | "PYG" | "QAR" | "RON" | "RSD" | "RUB" | "RWF" | "SAR" | "SBD" | "SCR" | "SDG" | "SEK" | "SGD" | "SHP" | "SLL" | "SOS" | "SRD" | "SSP" | "STN" | "SVC" | "SYP" | "SZL" | "THB" | "TJS" | "TMT" | "TND" | "TOP" | "TRY" | "TTD" | "TWD" | "TZS" | "UAH" | "UGX" | "USD" | "USN" | "UYI" | "UYU" | "UYW" | "UZS" | "VES" | "VND" | "VUV" | "WST" | "XAF" | "XAG" | "XAU" | "XBA" | "XBB" | "XBC" | "XBD" | "XCD" | "XDR" | "XOF" | "XPD" | "XPF" | "XPT" | "XSU" | "XTS" | "XUA" | "XXX" | "YER" | "ZAR" | "ZMW" | "ZWL", Counterbalance>>>;
|
|
8
8
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
2
|
import { isly } from "isly";
|
|
3
|
-
import {
|
|
3
|
+
import { Counterbalance } from "./Counterbalance";
|
|
4
4
|
export var Counterbalances;
|
|
5
5
|
(function (Counterbalances) {
|
|
6
6
|
function add(addendee, addend) {
|
|
7
7
|
const result = {};
|
|
8
|
-
for (const [currency,
|
|
9
|
-
result[currency] =
|
|
8
|
+
for (const [currency, counterbalance] of Object.entries(addendee)) {
|
|
9
|
+
result[currency] = Counterbalance.add(currency, counterbalance, addend[currency] ?? { minted: {}, burned: {} });
|
|
10
10
|
}
|
|
11
11
|
return result;
|
|
12
12
|
}
|
|
13
13
|
Counterbalances.add = add;
|
|
14
|
-
Counterbalances.type = isly.record(isly.fromIs("isoly.Currency", isoly.Currency.is),
|
|
14
|
+
Counterbalances.type = isly.record(isly.fromIs("isoly.Currency", isoly.Currency.is), Counterbalance.type);
|
|
15
15
|
})(Counterbalances || (Counterbalances = {}));
|
|
16
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=Counterbalances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Counterbalances.js","sourceRoot":"../","sources":["Counterbalances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAIjD,MAAM,KAAW,eAAe,CAY/B;AAZD,WAAiB,eAAe;IAC/B,SAAgB,GAAG,CAAC,QAAyB,EAAE,MAAuB;QACrE,MAAM,MAAM,GAAoB,EAAE,CAAA;QAClC,KAAK,MAAM,CAAC,QAAQ,EAAE,cAAc,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAuC,EAAE,CAAC;YACzG,MAAM,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAA;QAChH,CAAC;QACD,OAAO,MAAM,CAAA;IACd,CAAC;IANe,mBAAG,MAMlB,CAAA;IACY,oBAAI,GAAG,IAAI,CAAC,MAAM,CAC9B,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAChD,cAAc,CAAC,IAAI,CACnB,CAAA;AACF,CAAC,EAZgB,eAAe,KAAf,eAAe,QAY/B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TraceLog } from "@cloudflare/workers-types";
|
|
2
|
+
import { isly } from "isly";
|
|
3
|
+
import { Realm } from "../../Realm";
|
|
4
|
+
import type { Log } from "../index";
|
|
5
|
+
export interface Configuration {
|
|
6
|
+
realm: Realm;
|
|
7
|
+
collection: string;
|
|
8
|
+
resource?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare namespace Configuration {
|
|
11
|
+
const type: isly.object.ExtendableType<Log.Message.Configuration>;
|
|
12
|
+
function fromTraceLog(trace: TraceLog | undefined): Pick<Log, "realm" | "collection" | "resource"> | undefined;
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isly } from "isly";
|
|
2
|
+
import { Realm } from "../../Realm";
|
|
3
|
+
export var Configuration;
|
|
4
|
+
(function (Configuration) {
|
|
5
|
+
Configuration.type = isly.object({
|
|
6
|
+
realm: Realm.type,
|
|
7
|
+
collection: isly.string(),
|
|
8
|
+
resource: isly.string().optional(),
|
|
9
|
+
});
|
|
10
|
+
function fromTraceLog(trace) {
|
|
11
|
+
return trace && Configuration.type.is(trace.message[0])
|
|
12
|
+
? {
|
|
13
|
+
realm: trace.message[0].realm,
|
|
14
|
+
collection: trace.message[0].collection,
|
|
15
|
+
resource: trace.message[0].resource,
|
|
16
|
+
}
|
|
17
|
+
: undefined;
|
|
18
|
+
}
|
|
19
|
+
Configuration.fromTraceLog = fromTraceLog;
|
|
20
|
+
})(Configuration || (Configuration = {}));
|
|
21
|
+
//# sourceMappingURL=Configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Configuration.js","sourceRoot":"../","sources":["Log/Message/Configuration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAQnC,MAAM,KAAW,aAAa,CAiB7B;AAjBD,WAAiB,aAAa;IAChB,kBAAI,GAAG,IAAI,CAAC,MAAM,CAAgB;QAC9C,KAAK,EAAE,KAAK,CAAC,IAAI;QACjB,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE;QACzB,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAClC,CAAC,CAAA;IACF,SAAgB,YAAY,CAC3B,KAA2B;QAE3B,OAAO,KAAK,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACtD,CAAC,CAAC;gBACA,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK;gBAC7B,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU;gBACvC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ;aAClC;YACH,CAAC,CAAC,SAAS,CAAA;IACb,CAAC;IAVe,0BAAY,eAU3B,CAAA;AACF,CAAC,EAjBgB,aAAa,KAAb,aAAa,QAiB7B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TraceLog } from "@cloudflare/workers-types";
|
|
2
|
+
import { isly } from "isly";
|
|
3
|
+
import type { Log } from "../index";
|
|
4
|
+
export interface Entry {
|
|
5
|
+
message: string;
|
|
6
|
+
resource?: string;
|
|
7
|
+
data?: any;
|
|
8
|
+
}
|
|
9
|
+
export declare namespace Entry {
|
|
10
|
+
const type: isly.object.ExtendableType<Log.Message.Entry>;
|
|
11
|
+
function fromEventLogs(trace: TraceLog): {
|
|
12
|
+
entry: Log.Entry;
|
|
13
|
+
resource: Log["resource"];
|
|
14
|
+
} | undefined;
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isly } from "isly";
|
|
2
|
+
export var Entry;
|
|
3
|
+
(function (Entry) {
|
|
4
|
+
Entry.type = isly.object({
|
|
5
|
+
message: isly.string(),
|
|
6
|
+
resource: isly.string().optional(),
|
|
7
|
+
data: isly.any().optional(),
|
|
8
|
+
});
|
|
9
|
+
function fromEventLogs(trace) {
|
|
10
|
+
return Entry.type.is(trace.message[0])
|
|
11
|
+
? {
|
|
12
|
+
entry: {
|
|
13
|
+
message: trace.message[0].message,
|
|
14
|
+
data: trace.message[0].data,
|
|
15
|
+
},
|
|
16
|
+
resource: trace.message[0].resource,
|
|
17
|
+
}
|
|
18
|
+
: undefined;
|
|
19
|
+
}
|
|
20
|
+
Entry.fromEventLogs = fromEventLogs;
|
|
21
|
+
})(Entry || (Entry = {}));
|
|
22
|
+
//# sourceMappingURL=Entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Entry.js","sourceRoot":"../","sources":["Log/Message/Entry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAQ3B,MAAM,KAAW,KAAK,CAiBrB;AAjBD,WAAiB,KAAK;IACR,UAAI,GAAG,IAAI,CAAC,MAAM,CAAQ;QACtC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE;QACtB,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAClC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;KAC3B,CAAC,CAAA;IACF,SAAgB,aAAa,CAAC,KAAe;QAC5C,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACrC,CAAC,CAAC;gBACA,KAAK,EAAE;oBACN,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO;oBACjC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI;iBAC3B;gBACD,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ;aAClC;YACH,CAAC,CAAC,SAAS,CAAA;IACb,CAAC;IAVe,mBAAa,gBAU5B,CAAA;AACF,CAAC,EAjBgB,KAAK,KAAL,KAAK,QAiBrB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TraceLog } from "@cloudflare/workers-types";
|
|
2
|
+
import type { Log } from "../index";
|
|
3
|
+
import { Configuration as MessageConfiguration } from "./Configuration";
|
|
4
|
+
import { Entry as MessageEntry } from "./Entry";
|
|
5
|
+
export type Message = MessageConfiguration | MessageEntry;
|
|
6
|
+
export declare namespace Message {
|
|
7
|
+
export import Configuration = MessageConfiguration;
|
|
8
|
+
export import Entry = MessageEntry;
|
|
9
|
+
function fromEventLogs(traces: TraceLog[]): Pick<Log, "realm" | "collection" | "resource" | "entries"> | undefined;
|
|
10
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Configuration as MessageConfiguration } from "./Configuration";
|
|
2
|
+
import { Entry as MessageEntry } from "./Entry";
|
|
3
|
+
export var Message;
|
|
4
|
+
(function (Message) {
|
|
5
|
+
Message.Configuration = MessageConfiguration;
|
|
6
|
+
Message.Entry = MessageEntry;
|
|
7
|
+
function fromEventLogs(traces) {
|
|
8
|
+
const configuration = Message.Configuration.fromTraceLog(traces.find(trace => Message.Configuration.type.is(trace.message[0])));
|
|
9
|
+
const result = configuration
|
|
10
|
+
? { ...configuration, entries: [] }
|
|
11
|
+
: undefined;
|
|
12
|
+
if (result)
|
|
13
|
+
for (const trace of traces) {
|
|
14
|
+
const logFragment = Message.Entry.fromEventLogs(trace);
|
|
15
|
+
logFragment?.resource && (result.resource ??= logFragment.resource);
|
|
16
|
+
logFragment?.entry && result.entries.push(logFragment.entry);
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
Message.fromEventLogs = fromEventLogs;
|
|
21
|
+
})(Message || (Message = {}));
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Log/Message/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,SAAS,CAAA;AAG/C,MAAM,KAAW,OAAO,CAoBvB;AApBD,WAAiB,OAAO;IACT,qBAAa,GAAG,oBAAoB,CAAA;IACpC,aAAK,GAAG,YAAY,CAAA;IAClC,SAAgB,aAAa,CAC5B,MAAkB;QAElB,MAAM,aAAa,GAClB,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC1G,MAAM,MAAM,GAA2E,aAAa;YACnG,CAAC,CAAC,EAAE,GAAG,aAAa,EAAE,OAAO,EAAE,EAAE,EAAE;YACnC,CAAC,CAAC,SAAS,CAAA;QACZ,IAAI,MAAM;YACT,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC5B,MAAM,WAAW,GAChB,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;gBACnC,WAAW,EAAE,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC,QAAQ,CAAC,CAAA;gBACnE,WAAW,EAAE,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;YAC7D,CAAC;QACF,OAAO,MAAM,CAAA;IACd,CAAC;IAhBe,qBAAa,gBAgB5B,CAAA;AACF,CAAC,EApBgB,OAAO,KAAP,OAAO,QAoBvB"}
|
package/dist/Log/index.d.ts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
+
import { isoly } from "isoly";
|
|
2
|
+
import { TraceItem } from "@cloudflare/workers-types";
|
|
3
|
+
import { isly } from "isly";
|
|
1
4
|
import { Identifier } from "../Identifier";
|
|
2
|
-
import {
|
|
3
|
-
import { Entry } from "./Entry";
|
|
4
|
-
|
|
5
|
+
import { Realm } from "../Realm";
|
|
6
|
+
import { Entry as LogEntry } from "./Entry";
|
|
7
|
+
import { Message as LogMessage } from "./Message";
|
|
8
|
+
export interface Log {
|
|
5
9
|
id: Identifier;
|
|
6
|
-
|
|
10
|
+
realm: Realm;
|
|
11
|
+
script?: string;
|
|
12
|
+
collection: string;
|
|
13
|
+
resource?: string;
|
|
14
|
+
entries: Log.Entry[];
|
|
15
|
+
created: isoly.DateTime;
|
|
7
16
|
}
|
|
8
17
|
export declare namespace Log {
|
|
9
|
-
|
|
10
|
-
|
|
18
|
+
export import Message = LogMessage;
|
|
19
|
+
export import Entry = LogEntry;
|
|
20
|
+
const type: isly.object.ExtendableType<Log>;
|
|
21
|
+
function fromEvents(events: TraceItem[]): Log[];
|
|
11
22
|
function configure(collection: string, realm: string | undefined, resource?: string): void;
|
|
12
23
|
function log(message: string, data?: any, resource?: string): void;
|
|
13
24
|
function warning(message: string, data?: any, resource?: string): void;
|
package/dist/Log/index.js
CHANGED
|
@@ -1,36 +1,61 @@
|
|
|
1
|
+
import { isoly } from "isoly";
|
|
2
|
+
import { isly } from "isly";
|
|
1
3
|
import { Identifier } from "../Identifier";
|
|
2
|
-
import {
|
|
3
|
-
import { Entry } from "./Entry";
|
|
4
|
+
import { Realm } from "../Realm";
|
|
5
|
+
import { Entry as LogEntry } from "./Entry";
|
|
6
|
+
import { Message as LogMessage } from "./Message";
|
|
4
7
|
export var Log;
|
|
5
8
|
(function (Log) {
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
Log.Message = LogMessage;
|
|
10
|
+
Log.Entry = LogEntry;
|
|
11
|
+
Log.type = isly.object({
|
|
12
|
+
id: Identifier.type,
|
|
13
|
+
realm: Realm.type,
|
|
14
|
+
script: isly.string(),
|
|
15
|
+
collection: isly.string(),
|
|
16
|
+
resource: isly.string().optional(),
|
|
17
|
+
entries: Log.Entry.type.array(),
|
|
18
|
+
created: isly.fromIs("isoly.DateTime", isoly.DateTime.is),
|
|
19
|
+
});
|
|
20
|
+
function fromEvents(events) {
|
|
21
|
+
const result = [];
|
|
22
|
+
for (const event of events) {
|
|
23
|
+
const created = event.eventTimestamp
|
|
24
|
+
? isoly.DateTime.create(event.eventTimestamp, "milliseconds")
|
|
25
|
+
: isoly.DateTime.now();
|
|
26
|
+
const message = Log.Message.fromEventLogs(event.logs);
|
|
27
|
+
if (message) {
|
|
28
|
+
const log = {
|
|
29
|
+
id: Identifier.generate(),
|
|
30
|
+
realm: message.realm,
|
|
31
|
+
collection: message.collection,
|
|
32
|
+
entries: message.entries,
|
|
33
|
+
created,
|
|
34
|
+
};
|
|
35
|
+
message.resource && (log.resource = message.resource);
|
|
36
|
+
event.scriptName && (log.script = event.scriptName);
|
|
37
|
+
result.push(log);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
8
41
|
}
|
|
9
|
-
Log.
|
|
10
|
-
function fromConfiguration(configuration) {
|
|
11
|
-
return {
|
|
12
|
-
id: Identifier.generate(),
|
|
13
|
-
...configuration,
|
|
14
|
-
entries: [],
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
Log.fromConfiguration = fromConfiguration;
|
|
42
|
+
Log.fromEvents = fromEvents;
|
|
18
43
|
function configure(collection, realm, resource) {
|
|
19
44
|
const configuration = { collection, realm, resource };
|
|
20
|
-
if (Configuration.type.is(configuration))
|
|
21
|
-
console.log(
|
|
45
|
+
if (Log.Message.Configuration.type.is(configuration))
|
|
46
|
+
console.log(configuration);
|
|
22
47
|
}
|
|
23
48
|
Log.configure = configure;
|
|
24
49
|
function log(message, data, resource) {
|
|
25
|
-
console.log(
|
|
50
|
+
console.log(Log.Entry.Message.to(message, data, resource));
|
|
26
51
|
}
|
|
27
52
|
Log.log = log;
|
|
28
53
|
function warning(message, data, resource) {
|
|
29
|
-
console.warn(
|
|
54
|
+
console.warn(Log.Entry.Message.to(message, data, resource));
|
|
30
55
|
}
|
|
31
56
|
Log.warning = warning;
|
|
32
57
|
function exception(message, data, resource) {
|
|
33
|
-
console.error(
|
|
58
|
+
console.error(Log.Entry.Message.to(message, data, resource));
|
|
34
59
|
}
|
|
35
60
|
Log.exception = exception;
|
|
36
61
|
})(Log || (Log = {}));
|