Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : SP Keyboard8 * File : Scripts/portal/create-asc-record.js9 * Description : Creates the App Store Connect record (iOS, fr-CA, SKU10 * spkeyboard-ios-001) of ai.spboucher.keyboard when absent.11 * Idempotent: answers EXISTS with the record id. TestFlight12 * only: nothing is submitted to any review.13 * Module : Scripts14 * Repository : https://git.spboucher.ai/sp-keyboard15 * Created : 2026-12-0116 * Last Modified : 2026-12-0117 *18 * Author : Simon-Pierre Boucher19 * Position : Professor of Finance20 * Institution : Université du Québec en Outaouais (UQO)21 * Organization : SP Boucher22 * Website : https://spboucher.ai23 * Git : https://git.spboucher.ai24 *25 * Preferred Contact: support@spboucher.ai26 * Development : dev@spboucher.ai27 * Support : support@spboucher.ai28 * Security/Admin : admin@spboucher.ai29 *30 * Copyright (c) 202631 * Simon-Pierre Boucher32 * All rights reserved where applicable. This file is governed by the33 * applicable project license, copyright notices and relevant law.34 * Existing third-party rights and notices remain unaffected.35 *36 * License : None specified (no license file in this repository)37 *38 * Do not embed credentials, private keys, access tokens,39 * certificates or confidential personal information.40 *41 * =============================================================================42 * END OF SP BOUCHER SOURCE HEADER43 * =============================================================================44 */4546async function main(){47 const bundleId='ai.spboucher.keyboard', sku='spkeyboard-ios-001', names=['SP Keyboard','SP Keyboard : clavier personnel','SP Keyboard — clavier Aurora'];48 let r=await fetch('/iris/v1/apps?filter[bundleId]='+bundleId+'&fields[apps]=name,bundleId,sku',{credentials:'include'});49 if(r.status>=300) return 'LIST FAIL '+r.status+' (session?)';50 let j=await r.json(); const ex=(j.data||[]).filter(a=>a.attributes.bundleId===bundleId);51 if(ex.length) return 'EXISTS id='+ex[0].id+' name='+ex[0].attributes.name+' sku='+ex[0].attributes.sku;52 for(const name of names){53 const body={data:{type:"apps",attributes:{sku,primaryLocale:"fr-CA",bundleId},relationships:{appStoreVersions:{data:[{type:"appStoreVersions",id:"${store-version-ios}"}]},appInfos:{data:[{type:"appInfos",id:"${new-appInfo-id}"}]}}},54 included:[{type:"appStoreVersions",id:"${store-version-ios}",attributes:{platform:"IOS",versionString:"1.0.0"},relationships:{appStoreVersionLocalizations:{data:[{type:"appStoreVersionLocalizations",id:"${new-appStoreVersionLocalization-id}"}]}}},55 {type:"appStoreVersionLocalizations",id:"${new-appStoreVersionLocalization-id}",attributes:{locale:"fr-CA"}},56 {type:"appInfos",id:"${new-appInfo-id}",relationships:{appInfoLocalizations:{data:[{type:"appInfoLocalizations",id:"${new-appInfoLocalization-id}"}]}}},57 {type:"appInfoLocalizations",id:"${new-appInfoLocalization-id}",attributes:{locale:"fr-CA",name}}]};58 r=await fetch('/iris/v1/apps',{method:'POST',credentials:'include',headers:{'Content-Type':'application/json','X-Csrf-Itc':'[asc-ui]'},body:JSON.stringify(body)});59 const t=await r.text();60 if(r.status<300){ const k=JSON.parse(t); return 'CREATED id='+k.data.id+' name='+name+' sku='+sku; }61 const msg=(()=>{try{return JSON.stringify(JSON.parse(t).errors.map(e=>[e.code,e.detail]))}catch(e){return t.slice(0,300)}})();62 if(!/name|NAME/.test(msg)||names.indexOf(name)===names.length-1) return 'FAIL '+r.status+' '+msg;63 }64}65