@adminide-stack/yantra-mobile 12.0.161-alpha.1 → 12.0.162-alpha.0
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.
|
@@ -5,6 +5,7 @@ import {gql}from'@apollo/client/index.js';const FREE_CREDITS_STATUS_FIELDS = gql
|
|
|
5
5
|
offerAvailable
|
|
6
6
|
dailyCredits
|
|
7
7
|
monthlyCredits
|
|
8
|
+
starterCredits
|
|
8
9
|
}
|
|
9
10
|
`;
|
|
10
11
|
const FREE_CREDITS_STATUS_QUERY = gql`
|
|
@@ -79,6 +80,12 @@ function shouldOfferFreeCredits(status) {
|
|
|
79
80
|
}
|
|
80
81
|
function freeCreditsCardView(status) {
|
|
81
82
|
const title = "Unlock your free AI credits";
|
|
83
|
+
if (status && status.starterCredits > 0) {
|
|
84
|
+
return {
|
|
85
|
+
title,
|
|
86
|
+
body: `Claim ${status.starterCredits.toLocaleString()} free AI credits to start chatting with Yantra - a one-time start, no card needed.`
|
|
87
|
+
};
|
|
88
|
+
}
|
|
82
89
|
if (!(status == null ? void 0 : status.dailyCredits)) {
|
|
83
90
|
return {
|
|
84
91
|
title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"freeCredits.js","sources":["../../../src/features/credits/freeCredits.ts"],"sourcesContent":["/**\n * The free tier is unlocked per organization - by claiming the offer or by joining through an\n * invite link - never handed out on sign-up. Until then every message is answered with a notice\n * to claim, so a person who cannot claim cannot use the app at all. On 2026-11-02 none of the\n * 11 newest phone accounts had claimed: the button only existed on the web.\n *\n * These are the web's two calls (`services/freeCredits.ts`) for the phone. They go through the\n * app's Apollo client: its auth link adds the token and keeps the `orgname` header set on a\n * call's context, and the resolvers take the org from that header.\n */\nimport { gql, type ApolloClient } from '@apollo/client';\n\nexport interface FreeCreditsStatus {\n unlocked: boolean;\n source: 'offer' | 'invite' | null;\n offerAvailable: boolean;\n dailyCredits: number;\n monthlyCredits: number;\n}\n\nconst FREE_CREDITS_STATUS_FIELDS = gql`\n fragment FreeCreditsStatusFields on FreeCreditsStatus {\n unlocked\n source\n offerAvailable\n dailyCredits\n monthlyCredits\n }\n`;\n\nexport const FREE_CREDITS_STATUS_QUERY = gql`\n query FreeCreditsStatus {\n freeCreditsStatus {\n ...FreeCreditsStatusFields\n }\n }\n ${FREE_CREDITS_STATUS_FIELDS}\n`;\n\nexport const CLAIM_FREE_CREDITS_MUTATION = gql`\n mutation ClaimFreeCredits {\n claimFreeCredits {\n ...FreeCreditsStatusFields\n }\n }\n ${FREE_CREDITS_STATUS_FIELDS}\n`;\n\nexport const FREE_CREDITS_CLAIM_FAILED = \"We couldn't unlock your free credits. Please try again.\";\n\ntype GraphqlClient = Pick<ApolloClient<unknown>, 'query' | 'mutate'>;\n\nconst orgContext = (orgName: string) => ({ headers: { orgname: orgName } });\n\n/** The org's free-tier status, or null when it cannot be read (treated as \"no offer\"). */\nexport async function fetchFreeCreditsStatus(\n client: GraphqlClient,\n orgName: string,\n): Promise<FreeCreditsStatus | null> {\n try {\n const { data } = await client.query<{ freeCreditsStatus: FreeCreditsStatus }>({\n query: FREE_CREDITS_STATUS_QUERY,\n context: orgContext(orgName),\n fetchPolicy: 'network-only',\n });\n return data?.freeCreditsStatus ?? null;\n } catch {\n return null;\n }\n}\n\n/** Unlock the free tier through the offer. Throws with the server's reason when refused. */\nexport async function claimFreeCredits(client: GraphqlClient, orgName: string): Promise<FreeCreditsStatus> {\n const { data, errors } = await client.mutate<{ claimFreeCredits: FreeCreditsStatus }>({\n mutation: CLAIM_FREE_CREDITS_MUTATION,\n context: orgContext(orgName),\n errorPolicy: 'all',\n });\n const status = data?.claimFreeCredits;\n if (!status) {\n throw new Error(errors?.[0]?.message || FREE_CREDITS_CLAIM_FAILED);\n }\n return status;\n}\n\n/** The chat's answer to an org that has not claimed: cdecli's `creditsRefusalReason`. */\nconst LOCKED_REPLY = /haven['’]t claimed your free Yantra credits/i;\n\nexport function isFreeCreditsLockedReply(text: string | null | undefined): boolean {\n return LOCKED_REPLY.test(text ?? '');\n}\n\ninterface ChatTurn {\n role: string;\n content?: string | null;\n attachments?: readonly unknown[] | null;\n}\n\n/**\n * The turn the notice refused, when the notice is the newest reply: what to send again once the\n * credits are claimed. Null when the conversation has moved on, so an old notice further up the\n * thread never offers anything.\n */\nexport function lockedTurnToResend<T extends ChatTurn>(messages: readonly T[]): T | null {\n const newest = messages[messages.length - 1];\n if (newest?.role !== 'assistant' || !isFreeCreditsLockedReply(newest.content)) return null;\n for (let i = messages.length - 2; i >= 0; i -= 1) {\n const prior = messages[i];\n if (prior?.role === 'user' && (prior.content?.trim() || prior.attachments?.length)) return prior;\n }\n return null;\n}\n\n/** Offer the claim while it can still be claimed; say nothing when the status is unreadable. */\nexport function shouldOfferFreeCredits(status: FreeCreditsStatus | null): boolean {\n return Boolean(status?.offerAvailable && !status.unlocked);\n}\n\nexport interface FreeCreditsCardView {\n title: string;\n body: string;\n}\n\n
|
|
1
|
+
{"version":3,"file":"freeCredits.js","sources":["../../../src/features/credits/freeCredits.ts"],"sourcesContent":["/**\n * The free tier is unlocked per organization - by claiming the offer or by joining through an\n * invite link - never handed out on sign-up. Until then every message is answered with a notice\n * to claim, so a person who cannot claim cannot use the app at all. On 2026-11-02 none of the\n * 11 newest phone accounts had claimed: the button only existed on the web.\n *\n * These are the web's two calls (`services/freeCredits.ts`) for the phone. They go through the\n * app's Apollo client: its auth link adds the token and keeps the `orgname` header set on a\n * call's context, and the resolvers take the org from that header.\n */\nimport { gql, type ApolloClient } from '@apollo/client';\n\nexport interface FreeCreditsStatus {\n unlocked: boolean;\n source: 'offer' | 'invite' | null;\n offerAvailable: boolean;\n dailyCredits: number;\n monthlyCredits: number;\n /**\n * The one-time starter grant (2026-11-03): claimed once, never refilled. Above 0 it is the whole\n * free tier, and `dailyCredits` and `monthlyCredits` are 0; 0 while the free tier is credits a day.\n * A backend from before it rejects the query, which reads as \"no offer\": ship billing first.\n */\n starterCredits: number;\n}\n\nconst FREE_CREDITS_STATUS_FIELDS = gql`\n fragment FreeCreditsStatusFields on FreeCreditsStatus {\n unlocked\n source\n offerAvailable\n dailyCredits\n monthlyCredits\n starterCredits\n }\n`;\n\nexport const FREE_CREDITS_STATUS_QUERY = gql`\n query FreeCreditsStatus {\n freeCreditsStatus {\n ...FreeCreditsStatusFields\n }\n }\n ${FREE_CREDITS_STATUS_FIELDS}\n`;\n\nexport const CLAIM_FREE_CREDITS_MUTATION = gql`\n mutation ClaimFreeCredits {\n claimFreeCredits {\n ...FreeCreditsStatusFields\n }\n }\n ${FREE_CREDITS_STATUS_FIELDS}\n`;\n\nexport const FREE_CREDITS_CLAIM_FAILED = \"We couldn't unlock your free credits. Please try again.\";\n\ntype GraphqlClient = Pick<ApolloClient<unknown>, 'query' | 'mutate'>;\n\nconst orgContext = (orgName: string) => ({ headers: { orgname: orgName } });\n\n/** The org's free-tier status, or null when it cannot be read (treated as \"no offer\"). */\nexport async function fetchFreeCreditsStatus(\n client: GraphqlClient,\n orgName: string,\n): Promise<FreeCreditsStatus | null> {\n try {\n const { data } = await client.query<{ freeCreditsStatus: FreeCreditsStatus }>({\n query: FREE_CREDITS_STATUS_QUERY,\n context: orgContext(orgName),\n fetchPolicy: 'network-only',\n });\n return data?.freeCreditsStatus ?? null;\n } catch {\n return null;\n }\n}\n\n/** Unlock the free tier through the offer. Throws with the server's reason when refused. */\nexport async function claimFreeCredits(client: GraphqlClient, orgName: string): Promise<FreeCreditsStatus> {\n const { data, errors } = await client.mutate<{ claimFreeCredits: FreeCreditsStatus }>({\n mutation: CLAIM_FREE_CREDITS_MUTATION,\n context: orgContext(orgName),\n errorPolicy: 'all',\n });\n const status = data?.claimFreeCredits;\n if (!status) {\n throw new Error(errors?.[0]?.message || FREE_CREDITS_CLAIM_FAILED);\n }\n return status;\n}\n\n/** The chat's answer to an org that has not claimed: cdecli's `creditsRefusalReason`. */\nconst LOCKED_REPLY = /haven['’]t claimed your free Yantra credits/i;\n\nexport function isFreeCreditsLockedReply(text: string | null | undefined): boolean {\n return LOCKED_REPLY.test(text ?? '');\n}\n\ninterface ChatTurn {\n role: string;\n content?: string | null;\n attachments?: readonly unknown[] | null;\n}\n\n/**\n * The turn the notice refused, when the notice is the newest reply: what to send again once the\n * credits are claimed. Null when the conversation has moved on, so an old notice further up the\n * thread never offers anything.\n */\nexport function lockedTurnToResend<T extends ChatTurn>(messages: readonly T[]): T | null {\n const newest = messages[messages.length - 1];\n if (newest?.role !== 'assistant' || !isFreeCreditsLockedReply(newest.content)) return null;\n for (let i = messages.length - 2; i >= 0; i -= 1) {\n const prior = messages[i];\n if (prior?.role === 'user' && (prior.content?.trim() || prior.attachments?.length)) return prior;\n }\n return null;\n}\n\n/** Offer the claim while it can still be claimed; say nothing when the status is unreadable. */\nexport function shouldOfferFreeCredits(status: FreeCreditsStatus | null): boolean {\n return Boolean(status?.offerAvailable && !status.unlocked);\n}\n\nexport interface FreeCreditsCardView {\n title: string;\n body: string;\n}\n\n/**\n * What the card says. The credit numbers are the server's, so it can never promise a stale amount,\n * and a starter grant, which never refills, is never offered as credits a day.\n */\nexport function freeCreditsCardView(status: FreeCreditsStatus | null): FreeCreditsCardView {\n const title = 'Unlock your free AI credits';\n if (status && status.starterCredits > 0) {\n return {\n title,\n body: `Claim ${status.starterCredits.toLocaleString()} free AI credits to start chatting with Yantra - a one-time start, no card needed.`,\n };\n }\n if (!status?.dailyCredits) {\n return { title, body: 'Claim your free credits to start chatting with Yantra.' };\n }\n return {\n title,\n body: `Claim ${status.dailyCredits.toLocaleString()} free AI credits a day, up to ${status.monthlyCredits.toLocaleString()} a month.`,\n };\n}\n"],"names":[],"mappings":"0CAwBA,MAAM,0BAA6B,GAAA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAU5B,MAAM,yBAA4B,GAAA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,EAMnC,0BAA0B;AAAA;AAEzB,MAAM,2BAA8B,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AAuD,EAAA;AACzF,EAAA,MAAM,KAAQ,GAAA,6BAAA;AACd,EAAI,IAAA,MAAA,IAAU,MAAO,CAAA,cAAA,GAAiB,CAAG,EAAA;AACvC,IAAO,OAAA;AAAA,MACL,KAAA;AAAA,MACA,IAAM,EAAA,CAAA,MAAA,EAAS,MAAO,CAAA,cAAA,CAAe,gBAAgB,CAAA,kFAAA;AAAA,KACvD;AAAA;AAEF,EAAI,IAAA,EAAC,iCAAQ,YAAc,CAAA,EAAA;AACzB,IAAO,OAAA;AAAA,MACL,KAAA;AAAA,MACA,IAAM,EAAA;AAAA,KACR;AAAA;AAEF,EAAO,OAAA;AAAA,IACL,KAAA;AAAA,IACA,IAAA,EAAM,CAAS,MAAA,EAAA,MAAA,CAAO,YAAa,CAAA,cAAA,EAAgB,CAAiC,8BAAA,EAAA,MAAA,CAAO,cAAe,CAAA,cAAA,EAAgB,CAAA,SAAA;AAAA,GAC5H;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminide-stack/yantra-mobile",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.162-alpha.0",
|
|
4
4
|
"description": "Sample core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@messenger-box/platform-mobile": "*",
|
|
46
46
|
"@react-native-async-storage/async-storage": "*",
|
|
47
47
|
"@react-navigation/native": "*",
|
|
48
|
-
"common": "12.0.
|
|
48
|
+
"common": "12.0.161-alpha.1",
|
|
49
49
|
"expo-background-task": "*",
|
|
50
50
|
"expo-constants": "*",
|
|
51
51
|
"expo-secure-store": "*",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"typescript": {
|
|
68
68
|
"definition": "lib/index.d.ts"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "bb5d2d08e998240a7977958c9baefe9d4d008f2b"
|
|
71
71
|
}
|