SPB Git

Repository Public

create-asc-record.js 3.6 KB 63 lines javascript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Valo-Plex iOS8 * File             : Scripts/portal/create-asc-record.js9 * Module           : Scripts10 * Repository       : https://git.spboucher.ai/valo-plex-ios11 * Project Website  : https://www.valo-plex.com12 * Created          : 2026-12-0113 * Last Modified    : 2026-12-0114 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: support@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243// Valo-Plex iOS — Scripts/portal/create-asc-record.js44// Crée la fiche App Store Connect (iOS, fr-CA) du bundle com.spboucher.valoplex. Opération unique :45// relancée, elle signale que la fiche existe déjà.46// Author: Simon-Pierre Boucher — contact@spboucher.ai47async function create(bundleId, sku, names) {48  for (const name of names) {49    const body = {data:{type:"apps",attributes:{sku, primaryLocale:"fr-CA", bundleId},50      relationships:{appStoreVersions:{data:[{type:"appStoreVersions",id:"${store-version-ios}"}]},appInfos:{data:[{type:"appInfos",id:"${new-appInfo-id}"}]}}},51      included:[{type:"appStoreVersions",id:"${store-version-ios}",attributes:{platform:"IOS",versionString:"1.0.0"},relationships:{appStoreVersionLocalizations:{data:[{type:"appStoreVersionLocalizations",id:"${new-appStoreVersionLocalization-id}"}]}}},52        {type:"appStoreVersionLocalizations",id:"${new-appStoreVersionLocalization-id}",attributes:{locale:"fr-CA"}},53        {type:"appInfos",id:"${new-appInfo-id}",relationships:{appInfoLocalizations:{data:[{type:"appInfoLocalizations",id:"${new-appInfoLocalization-id}"}]}}},54        {type:"appInfoLocalizations",id:"${new-appInfoLocalization-id}",attributes:{locale:"fr-CA",name}}]};55    const r = await fetch('/iris/v1/apps',{method:'POST',credentials:'include',headers:{'Content-Type':'application/json','X-Csrf-Itc':'[asc-ui]'},body:JSON.stringify(body)});56    const t = await r.text();57    if (r.status < 300) { const j = JSON.parse(t); return bundleId+' OK id='+j.data.id+' name='+name; }58    const msg = (()=>{try{return JSON.stringify(JSON.parse(t).errors.map(e=>[e.code,e.detail,e.source]))}catch(e){return t.slice(0,400)}})();59    if (!/name|NAME/.test(msg) || names.indexOf(name) === names.length-1) return bundleId+' FAIL '+r.status+' '+msg;60  }61}62async function main(){ return await create('com.spboucher.valoplex','valoplex-ios',['Valo-Plex','Valo-Plex : valeur des plex','Valo-Plex Québec']); }63
Files main
Menu

Theme