Skip to content

Commit

Permalink
Regenerate the sdk to pick up internal payment field (#393)
Browse files Browse the repository at this point in the history
* Regenerate the sdk to pick up internal payment field (#9376)

GitOrigin-RevId: a77cd0f49148e5d875181eea27dcde6171548084

* Update from public js-sdk main branch (#9379)

Update public `js` sources with the latest code from the [public
repository](https://github.com/lightsparkdev/js-sdk) main branch.

This typically happens when new versions of the SDK are released and
version updates need to be synced. The PR should be merged as soon as
possible to avoid updates to webdev overwriting the changes in the
js-sdk develop branch.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Lightspark Eng <[email protected]>
Co-authored-by: Corey Martin <[email protected]>
GitOrigin-RevId: a14bd3a9db928c2e5b6af165eec1e36e812905df

* Create spicy-rockets-lay.md

---------

Co-authored-by: Jeremy Klein <[email protected]>
Co-authored-by: lightspark-ci-js-sdk[bot] <134011073+lightspark-ci-js-sdk[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Lightspark Eng <[email protected]>
Co-authored-by: Corey Martin <[email protected]>
  • Loading branch information
6 people authored Mar 8, 2024
1 parent 168060e commit a73d027
Show file tree
Hide file tree
Showing 37 changed files with 890 additions and 169 deletions.
6 changes: 6 additions & 0 deletions .changeset/spicy-rockets-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@lightsparkdev/lightspark-sdk": patch
"@lightsparkdev/wallet-sdk": patch
---

Regenerate the sdk to pick up internal payment field
5 changes: 5 additions & 0 deletions packages/lightspark-sdk/src/objects/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ query FetchAccountToApiTokensConnection($first: Int, $after: String) {
api_token_client_id: client_id
api_token_name: name
api_token_permissions: permissions
api_token_is_deleted: is_deleted
}
}
}
Expand Down Expand Up @@ -885,6 +886,7 @@ query FetchAccountToTransactionsConnection($first: Int, $after: String, $types:
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
incoming_payment_transaction_hash: transaction_hash
incoming_payment_is_uma: is_uma
incoming_payment_destination: destination {
id
}
Expand All @@ -903,6 +905,7 @@ query FetchAccountToTransactionsConnection($first: Int, $after: String, $types:
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
}
incoming_payment_is_internal_payment: is_internal_payment
}
... on OutgoingPayment {
__typename
Expand All @@ -920,6 +923,7 @@ query FetchAccountToTransactionsConnection($first: Int, $after: String, $types:
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
outgoing_payment_transaction_hash: transaction_hash
outgoing_payment_is_uma: is_uma
outgoing_payment_origin: origin {
id
}
Expand Down Expand Up @@ -1246,6 +1250,7 @@ query FetchAccountToTransactionsConnection($first: Int, $after: String, $types:
}
}
outgoing_payment_payment_preimage: payment_preimage
outgoing_payment_is_internal_payment: is_internal_payment
}
... on RoutingTransaction {
__typename
Expand Down
6 changes: 6 additions & 0 deletions packages/lightspark-sdk/src/objects/ApiToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ interface ApiToken {
/** A list of permissions granted to the token. **/
permissions: Permission[];

/** Whether the api token has been deleted. **/
isDeleted: boolean;

/** The typename of the object **/
typename: string;
}
Expand All @@ -48,6 +51,7 @@ export const ApiTokenFromJson = (obj: any): ApiToken => {
clientId: obj["api_token_client_id"],
name: obj["api_token_name"],
permissions: obj["api_token_permissions"].map((e) => Permission[e]),
isDeleted: obj["api_token_is_deleted"],
typename: "ApiToken",
} as ApiToken;
};
Expand All @@ -60,6 +64,7 @@ export const ApiTokenToJson = (obj: ApiToken): any => {
api_token_client_id: obj.clientId,
api_token_name: obj.name,
api_token_permissions: obj.permissions,
api_token_is_deleted: obj.isDeleted,
};
};

Expand All @@ -72,6 +77,7 @@ fragment ApiTokenFragment on ApiToken {
api_token_client_id: client_id
api_token_name: name
api_token_permissions: permissions
api_token_is_deleted: is_deleted
}`;

export const getApiTokenQuery = (id: string): Query<ApiToken> => {
Expand Down
96 changes: 96 additions & 0 deletions packages/lightspark-sdk/src/objects/AuditLogActor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

import { LightsparkException, type Query } from "@lightsparkdev/core";
import type ApiToken from "./ApiToken.js";
import Permission from "./Permission.js";

/** Audit log actor who called the GraphQL mutation **/
interface AuditLogActor {
/**
* The unique identifier of this entity across all Lightspark systems. Should be treated as an
* opaque string.
**/
id: string;

/** The date and time when the entity was first created. **/
createdAt: string;

/** The date and time when the entity was last updated. **/
updatedAt: string;

/** The typename of the object **/
typename: string;
}

export const AuditLogActorFromJson = (obj: any): AuditLogActor => {
if (obj["__typename"] == "ApiToken") {
return {
id: obj["api_token_id"],
createdAt: obj["api_token_created_at"],
updatedAt: obj["api_token_updated_at"],
clientId: obj["api_token_client_id"],
name: obj["api_token_name"],
permissions: obj["api_token_permissions"].map((e) => Permission[e]),
isDeleted: obj["api_token_is_deleted"],
typename: "ApiToken",
} as ApiToken;
}
throw new LightsparkException(
"DeserializationError",
`Couldn't find a concrete type for interface AuditLogActor corresponding to the typename=${obj["__typename"]}`,
);
};
export const AuditLogActorToJson = (obj: AuditLogActor): any => {
if (obj.typename == "ApiToken") {
const apiToken = obj as ApiToken;
return {
__typename: "ApiToken",
api_token_id: apiToken.id,
api_token_created_at: apiToken.createdAt,
api_token_updated_at: apiToken.updatedAt,
api_token_client_id: apiToken.clientId,
api_token_name: apiToken.name,
api_token_permissions: apiToken.permissions,
api_token_is_deleted: apiToken.isDeleted,
};
}
throw new LightsparkException(
"DeserializationError",
`Couldn't find a concrete type for interface AuditLogActor corresponding to the typename=${obj.typename}`,
);
};

export const FRAGMENT = `
fragment AuditLogActorFragment on AuditLogActor {
__typename
... on ApiToken {
__typename
api_token_id: id
api_token_created_at: created_at
api_token_updated_at: updated_at
api_token_client_id: client_id
api_token_name: name
api_token_permissions: permissions
api_token_is_deleted: is_deleted
}
}`;

export const getAuditLogActorQuery = (id: string): Query<AuditLogActor> => {
return {
queryPayload: `
query GetAuditLogActor($id: ID!) {
entity(id: $id) {
... on AuditLogActor {
...AuditLogActorFragment
}
}
}
${FRAGMENT}
`,
variables: { id },
constructObject: (data: any) => AuditLogActorFromJson(data.entity),
};
};

export default AuditLogActor;
4 changes: 4 additions & 0 deletions packages/lightspark-sdk/src/objects/CancelInvoiceInput.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

/**
* The unique identifier of the Invoice that should be cancelled. The invoice is supposed to be
* open, not settled and not expired. *
*/
interface CancelInvoiceInput {
invoiceId: string;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/lightspark-sdk/src/objects/CancelInvoiceOutput.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

/**
* The Invoice that was cancelled. If the invoice was already cancelled, the same invoice is
* returned. *
*/
interface CancelInvoiceOutput {
invoiceId: string;
}
Expand Down
85 changes: 68 additions & 17 deletions packages/lightspark-sdk/src/objects/ChannelSnapshot.ts
Original file line number Diff line number Diff line change
@@ -1,77 +1,105 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

import { type Query } from "@lightsparkdev/core";
import type CurrencyAmount from "./CurrencyAmount.js";
import {
CurrencyAmountFromJson,
CurrencyAmountToJson,
} from "./CurrencyAmount.js";

interface ChannelSnapshot {
/**
* The unique identifier of this entity across all Lightspark systems. Should be treated as an
* opaque string.
**/
id: string;

/** The date and time when the entity was first created. **/
createdAt: string;

/** The date and time when the entity was last updated. **/
updatedAt: string;

channelId: string;

/** The timestamp that was used to query the snapshot of the channel **/
timestamp: string;

/** The typename of the object **/
typename: string;

localBalance?: CurrencyAmount | undefined;

localUnsettledBalance?: CurrencyAmount | undefined;

localChannelReserve?: CurrencyAmount | undefined;

remoteBalance?: CurrencyAmount | undefined;

remoteUnsettledBalance?: CurrencyAmount | undefined;

status?: string | undefined;

localChannelReserve?: CurrencyAmount | undefined;
}

export const ChannelSnapshotFromJson = (obj: any): ChannelSnapshot => {
return {
id: obj["channel_snapshot_id"],
createdAt: obj["channel_snapshot_created_at"],
updatedAt: obj["channel_snapshot_updated_at"],
channelId: obj["channel_snapshot_channel"].id,
timestamp: obj["channel_snapshot_timestamp"],
typename: "ChannelSnapshot",
localBalance: !!obj["channel_snapshot_local_balance"]
? CurrencyAmountFromJson(obj["channel_snapshot_local_balance"])
: undefined,
localUnsettledBalance: !!obj["channel_snapshot_local_unsettled_balance"]
? CurrencyAmountFromJson(obj["channel_snapshot_local_unsettled_balance"])
: undefined,
localChannelReserve: !!obj["channel_snapshot_local_channel_reserve"]
? CurrencyAmountFromJson(obj["channel_snapshot_local_channel_reserve"])
: undefined,
remoteBalance: !!obj["channel_snapshot_remote_balance"]
? CurrencyAmountFromJson(obj["channel_snapshot_remote_balance"])
: undefined,
remoteUnsettledBalance: !!obj["channel_snapshot_remote_unsettled_balance"]
? CurrencyAmountFromJson(obj["channel_snapshot_remote_unsettled_balance"])
: undefined,
status: obj["channel_snapshot_status"],
localChannelReserve: !!obj["channel_snapshot_local_channel_reserve"]
? CurrencyAmountFromJson(obj["channel_snapshot_local_channel_reserve"])
: undefined,
} as ChannelSnapshot;
};
export const ChannelSnapshotToJson = (obj: ChannelSnapshot): any => {
return {
channel_snapshot_channel: { id: obj.channelId },
channel_snapshot_timestamp: obj.timestamp,
__typename: "ChannelSnapshot",
channel_snapshot_id: obj.id,
channel_snapshot_created_at: obj.createdAt,
channel_snapshot_updated_at: obj.updatedAt,
channel_snapshot_local_balance: obj.localBalance
? CurrencyAmountToJson(obj.localBalance)
: undefined,
channel_snapshot_local_unsettled_balance: obj.localUnsettledBalance
? CurrencyAmountToJson(obj.localUnsettledBalance)
: undefined,
channel_snapshot_local_channel_reserve: obj.localChannelReserve
? CurrencyAmountToJson(obj.localChannelReserve)
: undefined,
channel_snapshot_remote_balance: obj.remoteBalance
? CurrencyAmountToJson(obj.remoteBalance)
: undefined,
channel_snapshot_remote_unsettled_balance: obj.remoteUnsettledBalance
? CurrencyAmountToJson(obj.remoteUnsettledBalance)
: undefined,
channel_snapshot_status: obj.status,
channel_snapshot_channel: { id: obj.channelId },
channel_snapshot_local_channel_reserve: obj.localChannelReserve
? CurrencyAmountToJson(obj.localChannelReserve)
: undefined,
channel_snapshot_timestamp: obj.timestamp,
};
};

export const FRAGMENT = `
fragment ChannelSnapshotFragment on ChannelSnapshot {
__typename
channel_snapshot_channel: channel {
id
}
channel_snapshot_timestamp: timestamp
channel_snapshot_id: id
channel_snapshot_created_at: created_at
channel_snapshot_updated_at: updated_at
channel_snapshot_local_balance: local_balance {
__typename
currency_amount_original_value: original_value
Expand All @@ -88,30 +116,53 @@ fragment ChannelSnapshotFragment on ChannelSnapshot {
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_snapshot_local_channel_reserve: local_channel_reserve {
channel_snapshot_remote_balance: remote_balance {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_snapshot_remote_balance: remote_balance {
channel_snapshot_remote_unsettled_balance: remote_unsettled_balance {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_snapshot_remote_unsettled_balance: remote_unsettled_balance {
channel_snapshot_status: status
channel_snapshot_channel: channel {
id
}
channel_snapshot_local_channel_reserve: local_channel_reserve {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_snapshot_timestamp: timestamp
}`;

export const getChannelSnapshotQuery = (id: string): Query<ChannelSnapshot> => {
return {
queryPayload: `
query GetChannelSnapshot($id: ID!) {
entity(id: $id) {
... on ChannelSnapshot {
...ChannelSnapshotFragment
}
}
}
${FRAGMENT}
`,
variables: { id },
constructObject: (data: any) => ChannelSnapshotFromJson(data.entity),
};
};

export default ChannelSnapshot;
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

interface ClaimUmaInvitationInput {
/** The unique code that identifies this invitation and was shared by the inviter. **/
invitationCode: string;

/**
* The UMA of the user claiming the invitation. It will be sent to the inviter so that they can
* start transacting with the invitee.
**/
inviteeUma: string;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

interface ClaimUmaInvitationOutput {
/** An UMA.ME invitation object. **/
invitationId: string;
}

Expand Down
Loading

0 comments on commit a73d027

Please sign in to comment.